How to upgrade Wordpress SAFELY using Subversion and Rsync

I keep all my Wordpress projects in a Subversion repository. I also have a snapshot of unmodified ‘vanilla’ releases kept in the same repository.

Now theoretically I should simply be able to use the svn merge command in a working directory. But I have encountered serious problems, including file corruption warnings, when using svn merge in an actively developed working directory. Additionally, svn merge will delete files and directories that you added to the core Wordpress install.

The method outlined here will be safe even if you have hacked core Wordpress files, as long as you are very careful in constructing your rsync command.

  1. Import and tag the latest Wordpress release into the repository
    cd /tmp
    tar zxf /path/to/archive/wordpress-2.6.2.tar.gz
        OR
    unzip /path/to/archive/wordpress-2.6.2.zip
    svn import -m "Vanilla 2.6.2" wordpress file:///repository/wordpress/tags/2.6.2
  2. Remove the directory in /tmp
    rm -rf /tmp/wordpress
  3. Check out a fresh copy of your Wordpress project, and export a copy of the latest vanilla Wordpress
    cd /tmp
    svn co --ignore-externals file:///repository/wordpress/projects/myhappyblog
    svn export file:///repository/wordpress/tags/2.6.2 wordpress-2.6.2
  4. Do a dry run of rsync, starting with something like the following
    rsync --dry-run -av --delete --svn-exclude --exclude '.svn/' --exclude favicon.ico wordpress-2.6.2/ myhappyblog/|less -SiX
  5. Now begins an iterative process – carefully examine the output from the above rsync dry run, paying special attention to files that will be deleted, since those will show you directories and files you have added. Add those directories or files as required using multiple ‘–exclude’ options. Here is an example from a recent upgrade I did:
    rsync --dry-run -av --delete --svn-exclude --exclude '.svn/' --exclude favicon.ico --exclude 'images/' --exclude 'wp-content/plugins/podpress' --exclude 'wp-content/themes/sandbox' --exclude 'wp-content/uploads' wordpress-2.6.2/ myhappyblog/|less -SiX
  6. Once you are satisfied that you are not asking rsync to delete files and directories you need, run the command without ‘–dry-run’
    rsync -av --delete --svn-exclude --exclude '.svn/' --exclude favicon.ico --exclude 'images/' --exclude 'wp-content/plugins/podpress' --exclude 'wp-content/themes/sandbox' --exclude 'wp-content/uploads' wordpress-2.6.2/ myhappyblog/
  7. Now change to your project working directory and look at the output of ’svn stat’, here including sample output:
    svn stat
    
    M      wp-login.php
    M      wp-includes/post.php
    M      wp-includes/version.php
    M      wp-includes/query.php
    M      wp-includes/formatting.php
    M      wp-includes/pluggable.php
    M      wp-includes/widgets.php
    M      wp-settings.php
    M      wp-admin/includes/template.php
    M      wp-admin/includes/image.php
    M      wp-admin/import/textpattern.php
    M      wp-admin/css/press-this-ie.css
  8. (conditional) In major upgrades, there will be Wordpress core file deletions and additions. Handling these will require an extra couple commands, shown below. These commands are only necessary if there are additions and deletions.
    # tell repository about deleted files that were removed by rsync
    svn remove --force `svn stat |egrep '^\!' | cut -d' ' -f2-999`
    # add new files to repository
    svn add `svn stat|egrep '^\?' | cut -d' ' -f2-999`
  9. You may choose to look through all the changes, or you may decide that the files that have been changed are safe (ie, unhacked Wordpress core files).Now you are ready to commit the changes to the repository.
    svn diff | less # optional
    svn commit -m "Upgraded to Wordpress 2.6.2"
  10. At long last, you can go to the working directory where you are actively developing, and update that. Once you have tested thoroughly, you will be ready to update your live site (possibly with the same ’svn update’ command).
    cd /path/to/my/development/myhappyblog
    svn up
  11. Repeat from Step 3 for each of your SVN-managed Wordpress projects!
  12. Drink. Pray that Wordpress is not upgraded for at least another 6 months.
This entry was posted in Development, wordpress and tagged , , , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

2 Comments

  1. Posted November 5, 2009 at 11:29 pm | Permalink

    Excellent. Thanks for this.

  2. Posted December 24, 2009 at 6:44 am | Permalink

    Thanks for the great article. This is very helpful.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*
  • randy moss combine results
  • tea party zombies download
  • search 78search 800 numbers
  • randy moss bio
  • dis systems
  • archos
  • randy moss yahoo stats
  • roses
  • dis quand reviendras-tu
  • xanadu bengals
  • zara phillips and the queen
  • 4pm cspancspan area 51cspan 90.1
  • freida pinto miral
  • search lsu.edu
  • mtv oddities
  • seagate
  • battleship aurora
  • greg olsen university of miami
  • mtv kings of leon
  • chad ochocinco sisterchad ochocinco twitter
  • tolerance
  • search engines cookiessearch engines definition
  • bonus
  • gears
  • hartmann
  • dis 0 0.9
  • vince young yahoo stats
  • radar
  • beers
  • search 2.0
  • homeless
  • dis boards cruise
  • search engines us
  • chad ochocinco johnson
  • bengals qb situation
  • gregg olsen books
  • zara phillips dating
  • vince young uncle rico gif
  • freida pinto green dress
  • bea luna
  • chicago bears media relations
  • framed
  • la ink 2011 season 5
  • deed
  • battleship vittorio veneto
  • di's hallmark
  • meant
  • chicago bears 61
  • vince young depression
  • cspan hosts
  • ratchet
  • new england patriots gillette stadium
  • chicago bears 08 record
  • chicago bears bleacher report
  • battleship yamato wreck
  • chicago bears training camp
  • la ink corey
  • chicago bears 1985
  • search engines watch
  • search engines questions
  • pendant
  • cspan facebook
  • connecticut renaissance faire
  • battleship egg hunt
  • serenity
  • kilo
  • bangles eternal flame mp3bengals forum
  • prairie
  • afternoon
  • greg olsen vikingsgreg olsen wife
  • springhill
  • tea party birthday
  • vince young quiz
  • bea zuberbühler
  • battleship ipad
  • betty
  • search engines of the world
  • bea 0b0 105
  • dis x
  • chicago bears tattoos
  • greg olsen vancouver
  • hp support 530
  • chicago bears expo
  • quran
  • legend
  • search engines 9
  • 60 search engines virus
  • zara phillips baby
  • freida pinto zac posen
  • connecticut education
  • battleship yamato 2010
  • search vim
  • hp support error 1005
  • pads
  • connecticut post
  • mtv executivesmtv fantasy factory
  • connecticut secretary of state
  • search 990 finder
  • rooster
  • homeowners
  • wein
  • chicago bears 96
  • vince young yahoo stats
  • worst
  • c span yesterdayc span zelaya
  • randy moss jail
  • new england patriots 98.5
  • hp support quick test pro
  • zara phillips baby
  • la ink games online
  • chicago bears pictures
  • chad ochocinco bears
  • zara phillips wedding hat
  • chad ochocinco vs skip bayless
  • chad ochocinco and cheryl burke
  • new england patriots jake locker
  • tijuana
  • hp support englandhp support forum
  • bengals arrests
  • c span video contest
  • mtv dougie
  • new england patriots 80
  • tea party zombies download
  • vince young redskins
  • cspan presidents
  • palma
  • bear gryllsbea hive dance studio
  • zara phillips kids
  • battleship galactica
  • randy moss 98 vikings
  • beagle
  • extending
  • hp support id
  • connecticut 5th district
  • vince young football camp
  • search tumblr
  • la ink cast
  • search 32
  • battleship wilmington nc
  • randy moss 07 08 highlights
  • hose
  • dis pater
  • crimper
  • la ink 03x05
  • mandolin
  • hp support 6500a plus
  • battleship bismarck wreck
  • search engines before google
  • cspan washington correspondents dinner 2011
  • reign
  • chad ochocinco quotes video
  • bea goldfishberg
  • dependency
  • spherical
  • coronado
  • randy moss vikings 2011
  • battleship lexington
  • mtv true life
  • vince young endorsementsvince young foundation
  • hiding
  • search and seizure
  • search engines usage statistics 2010
  • connecticut lottery
  • dressing
  • licensed
  • mtv overdrive
  • tea party nj
  • hp support chat
  • hp support greece
  • connecticut juvenile training schoolconnecticut kids
  • hp support error 1005
  • dis lyrics
  • bea 71 series staples
  • odessey
  • bea test
  • mtv 5 cover
  • new england patriots needs
  • la ink 04x01
  • vince young 99 yard video
  • rotation
  • search operatorssearch people
  • battleship hacked
  • bea verdi
  • zara phillips fascinator