EasyWPUpdate for WordPress 2.2 (and earlier)
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!
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
Damn straight! 😉
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!
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!
I’m on 4.1.22-log
Whatever. It works!
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.
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.
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?
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/
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.
Brilliant, thanks! I hate updating WP, but was able to update 7 blogs today using the script. Seems to have worked like a charm.
What? I thought I sent you the email. Well. That would explain a few things. Let me find where I put it. 😀
http://mostlynothing.info/code/webrunner
Thats the page. 🙂
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’
?
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.
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.
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.
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.
Cool. Definitely a good thing to keep in mind. Thanks again.
@Brian – Yeah, I agree.
Also, did you get the link?
Bug…
Brian,
Any chance that this script might be tweaked for the 2.3 version of WordPress?
Rod – the script works for 2.3.x.
Well, it didn’t break anything for me, anyway.
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.
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.
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.
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.
Say, does 1and1 support fantastico and PHPmyadmin?
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.
Okay, phpmyadmin was my main worry anyway.
Thanks!
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)
it’s true that your website is very good, and it’s all well organized here.http://www.novelainsensatocoracao.net