Blogie Blog

I am therefore I blog

 

  •  

 

Upgrading multiple WordPress installs

Warning: geeky content!

When WordPress 2.6.5 was released yesterday, that ‘Oh no, not again!’ sinking feeling was quite overwhelming this time. You see, I have 20-something WordPress installations already — imagine the time and effort it would take to upgrade all of them. Even if there was the WordPress Automatic Upgrade plugin, that would still mean having to access each WP dashboard and perform the semi-automatic upgrade (not fully automatic because you still have to manually click on stuff to begin and continue the process).

WPAU takes about 5 minutes to complete, a bit longer if you actually do download the backup files it generates for you. So, 20 x 5 = 100 minutes, or almost two hours! That is, if you don’t multitask and perform simultaneous upgrading — but I don’t like having sooo many browser tabs open.

So, I tried my hand on some hard-core Linux command line stuff. And it worked! I was able to upgrade all my sites to the latest WordPress version in under 2 minutes, not counting the time to learn the commands. To spare you the trouble of having to figure out the Linux commands on SSH yourself, here’s what I did.

arrow Make sure you have backups of your WordPress files and databases!

Let’s say your hosting setup is a VPS that allows you SSH or telnet access. And let’s assume that your website directory structure is /home/username/htdocs, where username is the unique identifier of each website account, and htdocs is where the public website files reside. For this how-to, let’s say you have three WP blogs with the following usernames: myblog1, myblog2, and myblog3.

• Download the latest WordPress zip file, and unzip it.

1
2
3
wget http://wordpress.org/latest.zip
unzip latest.zip
cd wordpress/

That should create a wordpress directory. Let’s say you downloaded the zip file in /home — so now you have /home/wordpress, and you’re there.

• The following commands will automate the upgrading process. Note: all of the commands will be executed only upon hitting enter after the last line.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
for acct in myblog1 myblog2 myblog3
do
mv /home/$acct/htdocs/wp-config.php /home/$acc/htdocs/config.bak
rm -f /home/$acct/htdocs/*.php
cp *.php /home/$acct/htdocs
mv /home/$acct/htdocs/config.bak /home/$acct/htdocs/wp-config.php
chown $acct:$acct /home/$acct/htdocs/*.php
mv /home/$acct/htdocs/wp-admin /home/$acct/htdocs/wpadmin.bak
cp -r wp-admin /home/$acct/htdocs/
chown -R $acct:$acct /home/$acct/htdocs/wp-admin
mv /home/$acct/htdocs/wp-includes /home/$acct/htdocs/wpinc.bak
cp -r wp-includes /home/$acct/htdocs/
chown -R $acct:$acct /home/$acct/htdocs/wp-includes
done

I know, I know. The process is pretty involved, but it’s well worth learning. What the above executions are supposed to do are the following: copies over the new WP files and directories to each website account (you can add as many accounts to the list after for acct in), while preserving the attributes of the original files. Each website account will also have backups of the wp-admin and wp-includes folders.

Notice that we didn’t touch the wp-contents folders of your blogs at all. That’s because there really is no need to do so when upgrading WordPress.

You might actually have a different directory structure in your hosting setup, like /var/www/domain_name/htdocs or /home/account_name/public_html. Simply replace the appropriate parts of the above code with your own directory structure. Note that, during execution of the commands, the variable $acct is replaced with each of the website accounts that you include in the list in the first line of the code (myblog1, etc.).

arrow Caution: In case you have WordPress installations that have modifications in the wp-admin or wp-includes folders, do not include those sites in the accounts list. The above commands actually replace these two folders with fresh ones — although, your old files would still be in the backup folders.

arrow [UPDATE] I’ve trimmed the script a bit, but the new set will work just as well. Also, please note that your server might have a different setup when it comes to account usernames. If so, the chown commands above will not work for you. You might have to do a separate set of commands for setting file/folder ownership.

With all of my WP sites safely upgraded to the latest version, now I can spend more time in the meatier aspects of blogging.

Btw, this has been my 200th post. banana cool

Possibly Related Posts:
Stuff to do when upgrading to WP2.5  |  WordPress 2.8-beta1  |  WordPress on your local machine  |  WordPress 2.8 rocks!  |  WordPress 2.5 is out!

15 Responses to “Upgrading multiple WordPress installs”

  1. Paul Villacorta 27 November 2008 at 10:03 am #

    hi blogie!!

    didn’t know yer making a shell script! w0oot!! This is a good script for those who have ssh access… I’m using putty for remote terminal access.. are you using the same tool too??

    Paul here!

  2. Blogie 27 November 2008 at 10:06 am #

    Hi Paul. Yes, I know it’s you — nasa name field ang full name mo eh.. razz

    Yep, I use PuTTY. But I’m not really an expert on Linux. I just know enough to be able to manage my servers.

  3. Winston 27 November 2008 at 10:14 am #

    I don’t use ssh.

  4. Paul Villacorta 27 November 2008 at 10:14 am #

    oh yes! big grin hahaha!

    checked on WP upgrade only five files were affected
    maybe we could just extract those five files from the package and do some scripting razz
    may ill try doing it tonight at home big grin ill get back to work na… hay..

  5. Paul Villacorta 27 November 2008 at 10:16 am #

    @winston
    yer a windows boi! Im a FreeBSD user.. UNIX / LINUX

  6. Blogie 27 November 2008 at 10:16 am #

    @Winston — You actually have SSH enabled in your hosting account. You can access it via cpanel or you can use PuTTY, which is an excellent proggy for shell access.

    @Paul — Yeah, only 5 WP files. Kaya man na sa scripting. Gawa ka! :)

  7. Kevin Paquet 27 November 2008 at 10:27 am #

    Each time I see the Upgrading message, the firs thing that pops out on my mind is..
    YAHOO. NEW FEATURES, until I realized that it showed 2.6.5, an increment in the second decimal, and then suddenly I went.. OH NOH, JUST A BUG FIX..
    I can’t wait for WP 2.7 and mass upgrade all those blogs, even those which I haven’t upgraded yet since 2.5 haha..

    I tried the Automatic Upgrade plugin ones.
    I won’t use it again, in short. natrauma naq ana.

  8. Blogie 27 November 2008 at 10:29 am #

    @Kevin — Yeah, WPAU was buggy before. Pati ako tinamaan nyan once, but I don’t remember anymore kung ano’ng nangyari. Anyway, OK na man sya ngayon. Even Matt recommends it.

  9. Ayel 27 November 2008 at 1:20 pm #

    Gotta try this! I really have trouble upgrading my wordpress blogs, especially when I haven’t learned about WPAU yet. Thanks for this.

  10. iceman9 29 November 2008 at 9:49 pm #

    hmm… it would be better to beta test the upgrade before performing the said upgrades, because this might cause some unwanted errors that someone is not expecting, (did i do it right?)

  11. Blogie 29 November 2008 at 9:57 pm #

    @iceman9 — That goes without saying. As with anything involving your blog’s settings, coding, etc., one must always test first. Still, it’s good that you mentioned this.

    I’m fortunate to have a test bed server. I tested these scripts on that machine several times before doing the deed.

  12. iceman9 29 November 2008 at 10:30 pm #

    @ Blogie

    wow! that’s great! this means less downtime more uptime I consider this a best practice before performing any upgrade/patch installs. cheers! good! performing these demanding technical tasks is indeed a nosebleed!.

  13. iceman9 29 November 2008 at 10:48 pm #

    @ Blogie

    i would like to ask? please? can you suggest to me a better domain registrar and hosting service? that’s not expensive? anyways; is goddady ok for domain registration and hosting? cheers

  14. Blogie 29 November 2008 at 10:51 pm #

    @iceman9 — Godaddy is probably the best in the world for domain registration and management. I’ve never tried them for hosting, but I’ve heard not very good things about their hosting service from several people.

    I offer hosting. If you’re interested, drop me a line.

  15. iceman9 30 November 2008 at 12:46 pm #

    @ Blogie

    cool! ill give u a buzz about hosting soon… cheers


Leave a Reply

Notify me of follow-up comments via email. You may also subscribe without commenting.

delivered prednisone buy prednisone tablets without rx purchase prednisone pay pal online without rx prednisone overnight where to purchase generic prednisone online without a rx cheap prednisone by money order next day prednisone delivery online pharmacy cod prednisone prednisone overnight prednisone without prescription cod prednisone without prescription shipped overnight express prednisone mastercard how to buy Paxil online without a rx how to order Paxil online without a prescription purchase Paxil online without prescription buy Paxil no visa online without prescription where can i buy Paxil without a rx Paxil free consultation fedex overnight delivery fedex Paxil overnight without a prescription buy Paxil amex online without rx Paxil without prescription overnight shipping Paxil online uk order overnight Paxil purchase Paxil without purchase online Paxil without rx Paxil fedex no prescription overnight Paxil c.o.d order Paxil online with overnight delivery order overnight prednisone canadian pharmacy accutane buy Flomax online no prescription where to buy cheap software software discounters discount software for government employees discount zone alarm software cheap pc software review tpa transfer pricing software buy masterwriter software discount bmi sesac price software development india software download shareware treo software download academic and software and discount save the cat software educational discount cheap ho9me design software discount financial software download mobile software software to stop impusive buying buy software for less keyloggers and buy and paypal not software nowbc westend order generic Orlistat game20for20imac Lasix no prescription overnight builder cheap buy xenical next day delivery xenical without a r x Maxalt usa Maxalt prices uk Valtrex generic Valtrex cash on delivery No presciption valtrex discount valtrex buying valtrex (no prescriptions needed for Buspar|buy Buspar with no prescription|online pharmacies Buspar|Buspar cheap|buy Buspar without rx|purchase rx Buspar without|Buspar purchase online|purchase Buspar online without rx|purchase Buspar free consultation|buy Buspar Online|buy Buspar american express|buy Buspar Online|buy cheap Buspar with dr. prescription|Buspar side effects|fedex Buspar without priscription|overnight Buspar without a rx|order cheap overnight Buspar|Buspar toronto|uk order Buspar|Buspar no doctors prescription|Buspar mexico|Buspar order|no prescription Buspar with fedex|order generic Buspar|buy Buspar without rx from us pharmacy|prezzo Buspar|Buspar 10mg|Buspar from canada|purchasing Buspar without a script|buy Buspar australia|purchase Buspar visa without prescription|online purchase Buspar|buy Buspar no perscription cod|buy Buspar drugs|buy Buspar with visa|buy Buspar without rx needed|buy Buspar without prescription|buy Buspar no prescription low cost|purchase purchasing Buspar without a script no prescription required Nolvadex buy cheap pharmacy Nolvadex usa windows server 2008 r2 enterprise x64 Lasix online prescription purchase cheap Flomax online 40 mg accutane buy effect Nolvadex wire transfer buy synthroid las vegas synthroid/thyroxine no prior rx low cost Nolvadex at Kentucky Avawam Buy accutane master card Lasix drug Lasix no doctors prescription buy zithromax cheap cod no rx purchase zithromax paypal without prescription Nolvadex overnight delivery fed ex Nolvadex 20 mg order Nolvadex prescription online buying Nolvadex online without rx buy Nolvadex d 20 buy 10 mg Nolvadex purchase zithromax no visa online without prescription purchase Valtrex overnight delivery order zithromax 100 mg visa buy zithromax 40mg fast delivery BUY zithromax COD purchase zithromax cod next day delivery buy 250mg zithromax mastercard buy zithromax online 500mg with mastercard cheapest finpecia available online Orlistat online order saturday delivery buy cheapest Valtrexbuy no prior prescription Valtrex buy Maxalt once a day Finpecia toronto order finpecia no visa buy herbal finpecia purchase maxalt amex online without prescription Valtrex without prescription shipped overnight express next day delivery on Buspar saturday next day delivery on Buspar saturday no perscription prednisone next day Buying prednisone online without a perscription discount valtrex purchase Crestor overnight delivery no prescripton Valtrex buy Valtrex no visa without rx free Zithromax order buy Zithromax online where can i purchase Buspar no rx buy mail order Valtrex buy online rx Arimidex without Cytotec without prescriptionwhere to buy Cytotec in brisbane buy Cytotec online india Lasix online without prescription adobe 8 install buy cheap Buspar on line Valtrex price Crestor online overnight delivery cod how to buy Prednisone without a prescription adobe acrobat ie helper adobe premiere elements 3 Proscar suppliers office 2007 student version order no prescription Crestor non rx cheap accutane 40 mg buy Tamsulosin canada Academic Software Discounts Photoshop For Sale Premiere Pro Cs4 wholesale valtrex cheap adobe web development adobe wikipedia buy Orlistat without a perscription how to buy Flomax without a prescription buy online rx Crestor without adobe reader japanese fonts Crestor on line buy Crestor on line law enforcement officers killed in 2007 buy in Orlistat uk Orlistat mexico adobe mac cs office proffesional 2007 Should I Buy Windows 7 software oem project buy Buspar with a visa buy Flomax 0.4mg blues and chili festival 2011 vancouver Microsoft 64 Bit Windows pinnacle tv center for windows 7 power director price Best Photo Editor Software best buy Valtrex purchase Orlistat without a prescription overnight shipping how to buy replacement windows buy Flomax canada mediavatar video converter professional key serial key windows xp sp3 oem buy Flomax visa microsoft works windows 7 downloads turbocad best price pro adobe cs7 3d studio max 9 buy purchase no perscription Crestor Fincar without prescription windows xp home oem edition product key cheap valtrex purchase Flomax no prescription cheap cheap sperry mega sale data buy adobe cs5.5 master collection mac cheap mac snow leopard song Valtrex without rx overnight shipping motion builder midi device price vs 2010 price buy cheap fedex Prednisone Flomax cheap quarkxpres 6.0 ddl how to purchase Buspar online without rxcheap Buspar no rx do you have to buy software for online courses buy Buspar toronto adobe template buy Tamsulosin cheap cheap generic Valtrex Valtrex without doctor prescription how to order Zithromax online without prescription buy Bupropion online cheap buy Amitriptyline diet pills buy Zithromax 500 mg buy Buspar without rx prednisone online buy saturday delivery purchase cheap online prednisone order overnight prednisone buy Arimidex without a rx Valtrex cheap Windows 2000 Updates Buy Windows Xp X64 Windows 2000 Programs buy on line Valtrex Adobe Creative Suite Master Collection 3 acon digital media acoustica premium 4.1.0.382 Orlistat tablets buy Cytotec in chicago Autocad 2010 Best Price valtrex online purchase Buy Finpecia 1mg with visa Buspar buy Prednisone fedex shipping buy Zithromax with amex windows security system purchasing accutane 40 mg online without prescription buy finpecia amex online finpecia wholesale Discount Microsoft WindowsLightroom 2 Windows 7Ms Office StandardPhotoshop Cs5 UpgradeComputer Monitors For SaleWindows Xp InstallSuite Microsoft OfficeAutocad Version 2007Adobe Acrobat 9.0 Standard DownloadIe8 Download For Windows 7Adobe Paint ShopMicrosoft Service Pack 2Free Download Adobe AcrobatStudent And Teacher EditionManage ImageAdobe Acrobat 7 Pro DownloadVista Home Premium To Windows 7 UltimateWindows 7 Home Premium Upgrade OemAdobe Creative Suite 5 Master Collection Student And Teacher EditionBuy Adobe Photoshop Lightroom 3Ms Office 2010 Home And StudentCompare Photo SoftwareMicrosoft Office Word Viewer 2010Windows 7 Upgrade Student Discount ProfessionalWindows 7 Updates DownloadCreative Suite WebAdobe Reader VistaMicrosoft Windows 7 Home Premium Upgrade 64 BitPhotoshop 2Ie8 Download For Windows 7Photoshop 2009Suite Microsoft OfficeMicrosoft Office 2007 VersionUpgrade Windows Vista To 7Autocad Lt 2010Autocad 2010 Best PriceDownload Acrobat Reader 8 hd tune pro buy Softmaker Office 2010 adobe acrobat pdfmaker Buspar ohne rezept paragon mac product key telecharger windows server 2003 .iso Valtrex overdose Prednisone without rx order Buspar pay pal online without rx where can i purchase Valtrex no rx buy generic Valtrex Valtrex drug online pharmacy Proscar purchase Proscar without prescription from us pharmacy fedex Cytotec overnight without a prescription order Cytotec without a rx overnight shipping is it legal to buy Cytotec from canada buy finpecia with a mastercard uk finpecia generic free finpecia windows xp gadget microsoft word to buy windows xp professional password adobe reader software finpecia ohne rezept cheap downloadable software microsoft cheap discount software windows email security window screens windows media audio to mp3 windows will not open victorian window microsoft vista ultimate price windows malicious buy cheap Orlistat under without rx Rosuvastatin tabletten buspar no doctor prescription windows lve discount microsoft software for students desk help software