In the past year, I have started using SVN to deploy my Drupal installations. In the following post I will discuss my own personal SVN deployment strategy. This strategy allows me to work locally on a WAMP installation, and use SVN to deploy my sites to their remote installations.
Disclaimer: By no means am I claiming this is the only way, or the best way to use SVN in conjunction with Drupal. But, it is a method that works well for me, and I thought I would share it with others. If anyone has any comments on how they deploy Drupal themselves, or possible ways I could improve my own deployment strategy, I would love to hear them.
I work on a number of different Drupal installations. I maintain my own site, as well as a number of client sites. In deciding my deployment strategy, I considered the following points:
In considering the above points, I decided on the following strategy. First, I need one central repository for Drupal core. This repository has to contain Drupal core, along with any alterations I have made to Drupal core (such as allowing for unlimited uploads per user by role in the upload module - a feature currently available). Every time I create a new site, I simply check out my core files into the new installation directory on the server where the new site will reside.
Drupal Core Deployment Schema

In putting together this strategy, I did the following:
svn update. This automatically updates the relevant files on each installation, and only takes a few seconds per installation. If necessary I run the update.php script, and the site is updated. I can literally update multiple sites in minutes, whereas it used to take hours, between downloading core, going through and checking all my core modifications in the new files, logging into each installation separately and uploading the entire core through FTPSo that takes care of the common file system (Drupal core) through all of my installations. Next is my deployment strategy for the 'all' folder (modules and themes) in each installation. For the most part, this will be different between each installation. There are some modules that are common to all installations, but I generally just add them to each installation as it is not really a big deal. My 'all' folder looks like this:
'All' Folder Deployment Schema

In working with this, I do the following:
svn udpate. This grabs all the newest code and updates the folder to the most current version of the modules and themesThrough the above two steps, I have now created a remote Drupal installation and a remote 'all' folder. This covers core, non-core modules, and non-core themes. All are versioned, and all are easily updatable after work done on my local installation. However, there are two more areas which need to be considered, the database, and the sites/default/files directory. As I build individual pages on my local installation through the admin interface, these are only stored in the database. The same goes for any other changes made through the admin interface. As such, I need a way to sync my databases between the installations. I have found the Backup and Migrate module to be excellent for this. It is made specifically for backing up Drupal installations and is one of the modules I install on every single site I create. I also create a respository for my database backups made through this module.
Database Backup Deployment Schema

To manage database backups, I do the following:
admin/content/backup_migrate/destination), and create a new destination called 'remote'. This destination won't actually be used on the local PC, but since the database is synced between the local installation and remote installation, I need to create the destination here or it will be overwritten each time I re-sync the databases. Note: all destinations, 'manual', 'scheduled' and 'remote', should ideally be placed outside your webroot so as to increase securityadmin/content/backup_migrate), and do a quick backup to the manual backups directoryadmin/content/backup_migrate/destination), and create a new destination called 'remote'. This remote directory WILL be used on the remote installation. This destination should also be placed outside the web root so as to increase securityadmin/content/backup_migrate/destination), and click on 'list files' for the 'remote' destionationAnd that just leaves the contents of the sites/default/files folder. I generally just upload these through FTP, as there is no real need for versioning of these files, and generally when I am creating a site, this folder is barely even used, as it is mainly files created through the admin interface.
So that is my Drupal SVN deployment strategy. I'm interested in hearing any ideas on how this can be improved, as by no means am I a pro, and/or hearing how other people use SVN with Drupal in order to facilitate a smooth workflow.
Comments:
Post new comment