One by one. That's my new Drupal site update mantra. Try as I might, I have not been able to find a tool or do-it-all script that can outdo a simple 3 step workflow for updating Drupal core.
I've been a Drush user for quite a while and I still hand it lots of the mundane tasks for many of the sites I manage. But Drush has failed me too many times to trust it implicitly. If you've ever Drush'd your way through a core upgrade you may know what I mean.
The simple, most straightforward, and most locked down way I know to update core safely is through 3 basic steps:
- Get your site running locally
- Update your site locally
- Push your local site to your live server
Doesn't that sound simple? It really is if you know your way around the command line.
To get your site running locally you can do the Drush rsync and sql-sync things, or you can run a command line script to do essentially the same thing. Here's an example:
#!/bin/bash
#
echo "Getting remote database: dbName from user@example.com ..."
ssh -p 2222 user@example.com "mysqldump -u dbUser -pdbPassword dbName | bzip2" | bzip2 -d > dump.sql
echo "Resetting local database: dbName ..."
echo "drop database dbName;" | mysql -u dbUser -pdbPassword
echo "create database dbName;" | mysql -u dbUser -pdbPassword
echo "Logging in and restoring db dump to dbName ..."
mysql -u dbUser -pdbPassword -h 127.0.0.1 dbName < dump.sql
echo "Deleting database dump ..."
rm dump.sql
echo "Database done!"
echo "Synching local files with remote ..."
rsync -e "ssh -p 2222" -axzc --progress --delete user@example.com:/home/myHost/public_html/example.com/ ~/Sites/example.dev
echo "All done!"Hopefully the sample code substitutions are straightforward enough that a few search and replace operations will allow you to take advantage of this. Note you will also need to have SSH enabled on your account. It's pretty standard these days, though you may need to request it to be turned on.
Now that your live site is working locally you can go in and delete all the files in the root, save for the sites folder. Then simply drop your latest Drupal version on top (after deleting the sites folder from the Drupal sources folder, of course).
Now your local development install of Drupal is up to date. Well, core is, but that's what we're after here.
Once you've tested everything and you're sure all is well, the last step is to push your Drupal development site to your live server. I use a simple rsync command to do that for me:
rsync -e "ssh -p 2222" -axzc --progress --exclude sites --exclude=".DS*" --stats ~/Sites/example.dev/ user@example.com:/home/myHost/public_html/example.comNote the sites folder is excluded from updating. I do this because many times .dev will contain sample data or partially completed modules or modules I'm investigating but not ready to deploy. I use a separate set of scripts, or Drupal's own module update subsystem for version 7, to update modules.
That's it. Drupal core is now up to date. All that remains is to check site status to see if update.php needs to run, and possibly to flush caches and/or run cron.