EasyWPUpdate for WordPress 2.2 (and earlier)

May 15, 2007

TESTED THROUGH WORDPRESS 2.5

The release of WordPress 2.2 is finaly at our doorstep.  You can find the download on the on the main download page here: http://wordpress.org/download/ or from the announcement here: http://wordpress.org/development/2007/05/wordpress-22/.  This has been an interesting release.  For the last month I’ve been concentrating on the new job, but in the middle of all that I did participate in the debate that ended with the original tag implementation being pulled from this release.  Matt M. showed some real maturity by being willing to step back from his implementation upon the recomendation of others.  Oh! and for info about the name of this release “Getz”  head on over to Matt’s site for some sweet tones to put you into the mood to upgrade…

Aaron Brazell, aka Mr. Boss Sir, has come through and delivered another one of his 10 Things You Should Know About WordPress 2.2 articles and does a pretty good job of describing the heart and soul of this release.

I’ve released an updated version of my EasyWPUpdate script which includes some of the suggestions I’ve had from my readers.  Now, I must admit that Aaron’s similar script is downright awesome and the absolute best script in the world (yes I must admit that because it was a condition of my employment with b5media (REALLY!)), but if you don’t have automated server backups and you don’t regularly backup your SQL files, you might want to try my lowly little script.

Its features include:

  • Many blogs in one shot
  • Any version of WP
  • Automaticly runs upgrade script
  • Cleans up all files
  • Can use hosted or local files as source
  • Can be croned to ensure backups and/or refresh of dirtied files
  • Backup of files to new directory
  • Backup of files tarball/li>
  • Backup of database to SQL text file
  • Backup of database to tar ball
  • Optional inclusion/exclusions of directories.
  • Error detection and safe aborts

You can peruse the text version, EasyWPUpdate.txt, here:
Here are the basic steps to install this script:
1. Use Telnet or Putty to connect to your website and log into the shell
2. Type the following line:
wget http://www.thecodecave.com/downloads/EasyWPUpdate
3. Type the following line:
chmod +x EasyWPUpdate
4. Use an editor to change the values in Step 1 and save it again.
5. Run the script by typing:
EasyWPUpdate

That’s it. You will have just made backups of the files and database and updated all of your blogs. When 2.2.1 or even 2.3 comes out, the process will be:
1. Log in
2. Type
EasyWPUpdate

And you are done.

Now, step 1 looks like this:

# ##################################################################
# Step 1. Tell the script where to find the blogs
# ##################################################################
# List all of your WordPress directories and urls here.
#
# Each Blog should have a BlogDir and a BlugURL.
# Each Blog should have its own number [1],[2],[3] etc
# Delete the ones you don’t need.
#
BlogDir[1]=’site1dir’
BlogURL[1]=’www.example.com’

BlogDir[2]=’site2/news’
BlogURL[2]=’www.site2.com/news’

BlogDir[3]=’wordpress’
BlogURL[3]=’blog.site3.com’

That isn’t that hard to change is it? Even in VI.

Some quick tips on editing the script
1. type
vi EasyWPUpdate
2. Hit i
3. Make your changes
4. Hit ESCAPE COLON W to save your changes (or skip this step to lose changes)
5. Hit ESCAPE COLON !Q to immediately quit

Also, if your root directory is accessible from the web, you might want to change the name of the script:
mv EasyWPUpdate SomeSneakyName

to prevent unauthorized access.

(If you are a guru, please read through all 6 setup steps (and the rest too) there may be things you want to change.)

Enjoy 2.2!

Comments

47 Responses to “EasyWPUpdate for WordPress 2.2 (and earlier)”

  1. Will on May 16th, 2007 2:24 pm

    Hi there. A *terrific* script, and it’s got me all very excited about the ease with which I can upgrade. But I have a problem :(

    Making Targeted Database Backups...
    Processing SQL Backup for: webs/the/path/tomysite
    mysql: unknown variable 'protocol=TCP'
    Could not retrieve table names. SQLBackup failed.

    MySQL’s on a different machine…but it should know this, right, by finding the server name from WP’s config file? Incidentally I’m running the script by doing “perl EasyWPUpdate” if that makes any difference

    Any clues?

    Thanks Brian!

    Will

  2. Aaron Brazell on May 16th, 2007 4:01 pm

    Aaron’s similar script is downright awesome and the absolute best script in the world (yes I must admit that because it was a condition of my employment with b5media (REALLY!))

    Damn straight! ;)

  3. Will on May 16th, 2007 5:57 pm

    Removing the protocol=tcp parameter has done the job! What a brilliant script. Two blogs upgraded, one 50mb database and a whole load of files backed up in about 15 seconds. Seriously impressed and very grateful!

  4. Brian on May 16th, 2007 6:07 pm

    HUH! Do you know what version of MySQL you use? If you only removed that, I don’t think you are communicating via named pipes or sockets. So maybe it is an older/custom version that communicates ONLY through TCPIP

    Anyway, Glad you got it to work!

  5. Will on May 16th, 2007 6:17 pm

    I’m on 4.1.22-log

    Whatever. It works!

  6. Joe on May 16th, 2007 6:50 pm

    This is the best scipt I’ve seen so far. :) But what about my WebRunner? You said you’d be including a link. Anyway I’m updating right now.

  7. Brian on May 16th, 2007 9:17 pm

    Actually I was wondering the same thing, I thought we’d left it so that you were going to post it and I would link to it, If you want to do it the other way around, just send me the latest.

  8. Eric on May 20th, 2007 12:50 pm

    Sorry if these are stupid questions — I haven’t used Putty and the shell for much…

    I’ve followed your steps above, using PuTTY, but when is comes time to run the script, I get the following:

    -bash: EasyWPUpdate: command not found

    Also, if the WP blog is in the root/main folder of the site (i.e., http://www.somesite.com), what value do you set for the BlogDir?

  9. Eric on May 20th, 2007 2:25 pm

    I found the answer to my first question, by using:

    ./EasyWPUpdate

    Still not sure what to put for BlogDir, though. Is it the file path? e.g., /home/some/dir/public_html/

  10. Brian on May 20th, 2007 4:56 pm

    If you only have one blog, you should just put the value as
    BlogDir[1]=.

    and that should do it for you!

    That’ll just tell the script to run out of the current directory.

  11. Eric on May 20th, 2007 5:53 pm

    Brilliant, thanks! I hate updating WP, but was able to update 7 blogs today using the script. Seems to have worked like a charm.

  12. Joe on May 20th, 2007 9:15 pm

    What? I thought I sent you the email. Well. That would explain a few things. Let me find where I put it. :D

  13. Joe on May 20th, 2007 10:10 pm
  14. James Joyner on May 23rd, 2007 12:19 pm

    This looks really cool but I don’t really understand step 4.

    I’m supposed to enter a me-relevant version of

    BlogDir[1]=’site1dir’
    BlogURL[1]=’www.example.com’

    BlogDir[2]=’site2/news’
    BlogURL[2]=’www.site2.com/news’

    BlogDir[3]=’wordpress’
    BlogURL[3]=’blog.site3.com’

    ?

  15. Aaron Brazell on May 23rd, 2007 12:30 pm

    James,

    If you have 2 blogs to upgrade, one in your website root and the second in a folder under your website root called sports, for instance, you’d run the script from your website root and do:


    BlogDir[1]='.'
    BlogURL[1]='www.outsidethebeltway.com'

    BlogDir[2]='sports'
    BlogURL[2]='www.outsidethebetlway.com/sports'

    Similar to that anyway. I’m assuming some information on what you’re hoping to upgrade, but that’s what I’d venture.

  16. Rod on May 23rd, 2007 6:01 pm

    Brian – thanks very much for this script. I’ve got two separate blogs on my server, and while the main one was current (2.2), the other was on 2.1.3. Until I tried the script, and after a little tweaking, it upgraded perfectly. Now I’ve got both configured for the next upgrade. Very much appreciated.

  17. Rod on May 25th, 2007 12:14 pm

    I was wondering if it’s necessary to disable all of the installed plugins before running the script? I did on the first upgrade I ran with the script, but if it’s not necessary, I’ll skip it the next time I run it.

  18. Brian on May 25th, 2007 1:07 pm

    No, it is not. That is something that 2.0 gave us. The plugin API eliminates most of the need. There is a SMALL chance that a plugin would be completely inoperable and stop an upgraded site, but on the very rare event that happens, you can go into PHP my admin to the options table, sort by option name and delete the the option value for “ActivePlugins” which should be at the top of the list. I asked the members of WP-Hackers and WP-Testers if they deactivated plugins before upgrading and every one that replied said they never did. Not one person spoke up for de-activating the plugins.

  19. Rod on May 25th, 2007 4:00 pm

    Cool. Definitely a good thing to keep in mind. Thanks again.

  20. Joe on May 25th, 2007 8:26 pm

    @Brian – Yeah, I agree.
    Also, did you get the link?

  21. Joe on July 7th, 2007 4:22 pm

    Bug…

  22. Rod Templeton on October 25th, 2007 9:43 pm

    Brian,

    Any chance that this script might be tweaked for the 2.3 version of WordPress?

  23. Les on October 27th, 2007 4:28 am

    Rod – the script works for 2.3.x.

    Well, it didn’t break anything for me, anyway.

  24. Brian on October 30th, 2007 1:16 am

    Yep, it is tested and working well.

    Now that I know a good bit more about scripting than I ever had before, I will be doing an update of this script.

    The WordPress installation process has come a ways, but because this script does the whole procedure of backing up both files AND database, it still has place.

    I get a lot of comfort out of knowing that all of my sites are backed up and cleaned on a regular basis.

  25. Kevin on October 30th, 2007 10:05 am

    Brian – keep up the good work with this script. At last count I’m using your script to keep 26 sites current. To say the least, I am deeply grateful for your script. Thank you.

  26. Rod on October 30th, 2007 12:27 pm

    Weird. I get the following error :

    cp: cannot open `/home/rod/public_html/wp-content/rtdn-backup/2007-09-25-08-20-34-full.tar.gz’ for reading: Permission denied

    This started with the upgrade to 2.3, and while that .gz file exists, I cannot change its mode (currently 600) or delete it. Permission denied to do either.

  27. Rod on October 30th, 2007 2:45 pm

    Actually it appears to have been a permission issue on my server. Not something I’d changed, but with the permissions set the correct way, the script runs fine again.

  28. steve on March 10th, 2008 1:34 pm

    Say, does 1and1 support fantastico and PHPmyadmin?

  29. Brian on March 13th, 2008 3:34 pm

    It supports phpmyadmin. It comes with it but I have my own preferred flavor installed.
    Fantastico I think requires cPanel which 1and1 doesn’t run. So I think the answer is no.

  30. steve on March 15th, 2008 9:22 pm

    Okay, phpmyadmin was my main worry anyway.
    Thanks!

  31. Chris Wadge on September 10th, 2008 2:29 am

    Hello again! Just a suggestion, but you might consider calling each CPU-intensive activity with nice, and giving the user the option to set the value. It’s not particularly useful on a single-site host, but on a shared box it would be quite appropriate I think. Something like this perhaps:

    NiceValue=”10″

    (nice -n $NiceValue tar –no-recursion -zcf “$BackupDir/$BackupTarballName” . –recursion $SubDirs)

Got something to say?





Cave Drips...

  • Apparently , I sometimes stuttutter when I type "fedederal" 15 hrs ago
  • I don't understand why ppl are still talking of Sarah Palin. She's not now & nevr was a serious candidate for any executive office position. 16 hrs ago
  • More updates...