Skip to content

Instantly share code, notes, and snippets.

@ianchanning
Last active December 24, 2015 13:49
Show Gist options
  • Save ianchanning/6808496 to your computer and use it in GitHub Desktop.
Save ianchanning/6808496 to your computer and use it in GitHub Desktop.
For upgrading WordPress when you've got a subversion installation. Backs up the database then upgrades WordPress to the specified version. A bit odd having subversion commands on github... but hey.
#!/bin/bash
# usage: svn_upgrade_wordpress.sh X.X.X
# http://codex.wordpress.org/Installing/Updating_WordPress_with_Subversion
# licence MIT
die () {
echo >&2 "$@"
exit 1
}
# check that there is one argument
[ "$#" -eq 1 ] || die "usage: upgrade_wordpress.sh X.X.X"
# http://stackoverflow.com/q/2220301/327074
response=$(curl --write-out %{http_code} --silent --output /dev/null http://core.svn.wordpress.org/tags/$1/)
# check that the tag repository exists, i.e. returns a HTTP 200 status code
[ "$response" -eq 200 ] || die "Couldn't find Wordpress version, http error: $response"
# Take a backup
mysqldump -u [database-user] -p[database-password] [database-name] > wordpress_upgrade_to_$1_bak.sql
# Updating to a New Stable Version
cd /path/to/wordpress/
svn sw http://core.svn.wordpress.org/tags/$1/ .
# Put the permissions back
chown -R [default-user]:[default-group] *
# chown -R www-data:www-data wp-content/uploads
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment