Using rsync to Update Wordpress

April 28, 2008

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 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:

  1. Download and expand the latest Wordpress version.
  2. Execute one rsync command for each site to be updated.
  3. Enjoy a beverage.
As always, before updating your Wordpress installation you should have a current, complete back up.  I will not be responsible for any lost files resulting from the following command.  


The basic format of rsync is
rsync [options] source_directory target_directory

Where [options] are the command options, sourcedirectory is the location of the files you want to synchronize, and targetdirectory is the location of the files to be synchronized.

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

Running the command with the -n switch is a good idea, if for nothing else to verify your source and target directories. (Once you run the command to your satisfaction using -n, simply edit the command from your shell history, and remove the "n" leaving the rest of the command untouched.)

Putting It Together

Here then, is the command as I run it to update my remotely hosted sites:

rsync -rav ~/Desktop/wordpress/ myUserName@myServerName:public_html/siteRoot

Obviously, you will need to substitute your username and server name.  After responding to a password prompt, the command executes and your Wordpress installation is updated from top to bottom, leaving any theme or plugins behind.  Any modifications you've made to Wordpress code will be overlaid, so you'll have to re-apply those once rsync is finished.

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.


Author's profile picture

Mark H. Nichols

I am a husband, cellist, code prole, nerd, technologist, and all around good guy living and working in fly-over country. You should follow me on Twitter.