[updated: Sep 30th, 2018 | Cleaned up script, and references “perfect” plugin update system]
NOTE: Please checkout my “perfect” WordPress plugin update solution: http://blog.vpetkov.net/2018/09/30/easy-fully-automated-wordpress-plugin-update-system
When you host your own WordPress installation, and there is some sort of an update about every month or so, it can quickly get very annoying doing all the upgrade steps manually (for the people who do not have a CPANEL or FTP account). Now imagine hosting 5-6 WordPress installations. Now imagine 100+. Welcome to my nightmare. Eventually I caved in and wrote this:
# This strictly follow the directions mentioned above.
# Utilizes: "rm", "cp", "mv", "wget", "unzip"
/bin/rm -Rf latest.zip
/usr/bin/unzip -q latest.zip
# Remove outdated CURRENT_BLOG files per instructions
/bin/rm -Rf wp-includes wp-admin
# Copy TEMP_NEW files per instructions
/bin/cp -Rf wp-includes $CURRENT_BLOG/.
/bin/cp -Rf wp-admin $CURRENT_BLOG/.
/bin/cp -Rf * $CURRENT_BLOG/wp-content/.
/bin/mv *.php $CURRENT_BLOG/.
/bin/mv readme.html $CURRENT_BLOG/.
/bin/mv license.txt $CURRENT_BLOG/.
# Cleanup TEMP_NEW - remove extraction and download.
/bin/rm -Rf wordpress latest.zip
echo "go to: http://$FQDN/wp-admin/upgrade.php"
So, to summarize, this will download the latest version of wordpress, unzip it, and move the new files accordingly.
At the end, it will remind you to “upgrade” your DB, just in case there is an upgrade. I highly suggest backing up your primary blog before you begin this, just because it’s the “safe thing” to do.
That said, in the 10+ years I’ve used this (started long before I posted something here) – I’ve never had anything go wrong!
Thanks, this is great!
Can you clarify what the $NEW and $OLD variables represent? I think $OLD is the location of your wordpress installation, and $NEW is a temporary folder where the wordpress distribution is unpacked, right? And $HOME is the folder that the wordpress distribution is downloaded to?
Hey, $OLD (poor choice for a variable name) is the “full current blog path”. It builds on $HOME. For example, something like $HOME=/var/www and $OLD would be $HOME/myblog. The $NEW variable is a temporary folder where the new wordpress is unpacked yes. I will fix these with something that makes more sense, and update it in Git and on my blog. Thanks for pointing this out.
Pingback: VPetkov.net » Script to Upgrade Pluggins on WordPress to the latest version fully automatically