WordPress Upgrade Commands

I’m using this series of commands to update blogs to the latest version of WordPress. It makes a backup of their entire WordPress directory to ../wp-upgrade-backup/ (in relation to their current WP directory), and makes sure to preserve their /wp-content/ directory as well as their /index.php

For those with SSH access to their server, this could be a timesaver. You just cd to your current WP directory and paste this in. A quick visit to /wp-admin/ to upgrade your database, and you’re in business.

WARNING: If this breaks things, I don’t want to hear it. If you don’t know enough to look through and see what you’re pasting, you deserve for bad things to happen to you.

# IMPORTANT!
# You must run this from within your current WordPress directory
# (i.e. the directory where wp-config.php resides)

# First, back up everything
mkdir ../wp-upgrade-backup/
cp -R . ../wp-upgrade-backup/

# download WP, unzip WP
wget -O wp.zip http://wordpress.org/latest.zip
unzip wp.zip -d wp-upgrade-TEMP/
rm wp.zip

# Remove files from the downloaded copy of WP that we don't want
rm -rf wp-upgrade-TEMP/wordpress/wp-content/ wp-upgrade-TEMP/wordpress/index.php

# Delete the current wp-includes and wp-admin directories and copy in the new ones
rm -rf wp-includes/
mv wp-upgrade-TEMP/wordpress/wp-includes/ .
rm -rf wp-admin/
mv wp-upgrade-TEMP/wordpress/wp-admin/ .
mv wp-upgrade-TEMP/wordpress/* .

# Remove the temporary directory
rm -rf wp-upgrade-TEMP/

# END

# You must now visit your /wp-admin/ to run the upgrade scripts

6 thoughts on “WordPress Upgrade Commands

Comments are closed.