Using rsync to Update Wordpress




I currently support four public facing sites that use Wordpress as the back-end content management system (CMS).  I also have a Wordpress test platform on my laptop, where I tinker with several different themes, that supports another four sites. So, I’ve got eight different Wordpress installations to update each time a new release is made available.  Running through the update steps is tedious at best and, with the need to not inadvertently overlay the theme or plugin directory in each installation, there is a fair amount of stress.  Using ftp to accomplish the update isn’t difficult, but after doing the same steps four or five or six times, it is easier to make a mistake.

Wordpress does provide instructions for how to accomplish site updates using Subversion.  Unfortunately, my host provider doesn’t have Subversion installed, nor are they inclined to add it just for me.  As I am comfortable with command line tools, I decided to investigate rsync as a solution for my update tasks.

Rsync

Rsync is remote synchronization software that allows you to keep files in two locations in sync with each other.  This is not a rsync tutorial, so I high encourage you to read the man page, or visit one of the numerous sites explaining this powerful tools uses.

For my purpose I want my Wordpress update steps to be the following:

There are a myriad of options for rsync, but the three (or four) that I used are:

To update my locally hosted test sites, which are built upon MAMP, the command looks like this:

rsync -rav ~/Desktop/wordpress/ /Applications/MAMP/htdocs/siteRoot
The final step would be to encapsulate the rsync commands in a shell script so they can be executed without the need to retype them each time they are needed. Or you could create an alias in your bash profile for each destination and execute the sync that way.