• Home
  • About
  • Archives
  • Books
  • Colophon
  • Policies
  • Resume
  • Tumblr

zanshin.net

because not enough websites start with the letter “Z”

Feed on
Posts
Comments
Tumblr
« Polymorphism: Music is Like Programming
Random, And Not Repetitive »

Using rsync to Update WordPress

Apr 28th, 2008 by mark

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:

  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.  

Basics

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

Where [options] are the command options, source_directory is the location of the files you want to synchronize, and target_directory 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:

  • -r : Recursive mode, recurses through all sub-directories contained within the source_directory
  • -a : Archive mode, which is equivalent to setting the -rlptgoD flags, for recursive, preservation of links, permissions, time, group, owner, and Device.
  • -v : Verbose mode, to see exactly what the command is doing
  • -n : Dry-run mode, shows the effect of the command without actually running it.

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.

 

Tags: rsync, wordpress

Posted in nerdliness

One Response to “Using rsync to Update WordPress”

  1. on 17 Jul 2008 at 7:21 am1zanshin.net » Wordpress Automatic Update » Blog Archive

    [...] of WordPress 2.6 this week I was preparing to update both my test sites and our public sites using the rsync method I wrote about in April.  Quite by happenstance I read an article on Download Squad about the [...]



  • Welcome!

    Mark H. Nichols is a software architect, martial artist, nerd, and all around good guy. He works at Kansas State University in Manhattan Kansas, and lives with his wife, two cats, a pair of 7-foot Kawai concert grand pianos, a violoncello, nearly a dozen computers, and a 2010 Honda Insight EX. You can read more about Mark, and this site, or explore the archives.
  • last 3 tweets

    • @thecurtain Do they have dry rub ribs? I haven't had good dry rub ribs since Charleston SC in about 2000. #hungrynow about 1 hour ago from Tweetie for Macin reply to thecurtain
    • @goldengateblond Ulanbator. about 6 hours ago from Tweetie for Macin reply to goldengateblond
    • Playing Towers of Hanoi with the tupperware bowls and lids. #fridaynight about 17 hours ago from Tweetie for Mac
    • Gimme an F. Gimme a R. Gimme an O. Gimme a Y. Gimme another O. What's it spell? FroYo! C'mon #HTC, I want my #FroYo. #incredible #android 01:12:19 PM July 30, 2010 from Tweetie for Mac
    • Create "ransom note" style phrases using typography from well-known brands. Try your name to really understand. http://iconscrabble.com/ #fb 01:14:04 PM July 29, 2010 from Tweetie for Mac
    • Run this on your work network: http://bit.ly/1sWqUc, it rates your DNS and generates calls from your security people. #voiceofexperience 08:27:09 PM July 27, 2010 from Tweetie for Mac
    • @jblanton BenPaper (http://hubpages.com/hub/How-to-use-Instapaper-on-AndroidDroidNexus-One) serves nicely as an @instapaper client. 06:40:47 PM July 27, 2010 from Tweetie for Macin reply to jblanton
    • I'm from the pronounce-individual-letters school, not the say-as-a-word school regarding acronyms. It's "ess-oh-ey" not "sow-ah." #soa 06:16:06 PM July 27, 2010 from Tweetie for Mac
    • @cholick I think my personal best is 74 days. Currently at 22 d 12 h. #macosx #uptime 03:20:45 PM July 27, 2010 from Tweetie for Macin reply to cholick
    • Comlete with magic Bluetooth fairy dust. http://bit.ly/a5Z79K http://bit.ly/aFhP83 #apple #magictrackpad 03:18:36 PM July 27, 2010 from Tweetie for Mac
  • Most Popluar

    • Installing PostgreSQL on Mac 10.6 (Snow Leopard)
    • Using jQuery to Create iGoogle Style Drag-and-Drop
    • geek. : nerdliness is next to godliness
    • Using SSHFS, MacFUSE, and Macfusion to Access Remote Filesystems
    • Solfège
    • Shotski’s Ring
    • Mac OS X 10.6.4 Update Fails
    • Solfège Slurs and Hooked Bowing
    • Apple Manifesto
  • Categories

    • diversions
    • elsewhere
    • family
    • health
    • life
    • links
    • meme
    • nerdliness
    • photography
    • random
    • relationships
    • social issues
  • Archives

    • Blogroll

      • Change.gov
      • Elfenbein Klaviermusik Notes
      • Shawn Blanc
      • Sibylle Kuder

zanshin.net © 1996 - 2010 All Rights Reserved.

Policies | Web Hosting: Blue Host