Created
January 10, 2011 23:50
-
-
Save GromNaN/773729 to your computer and use it in GitHub Desktop.
How-to update WordPress via SSH.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Settings | |
WORDPRESS=/var/www/sites/jerome.tamarelle.net/web/blog | |
VERSION=3.1 | |
BACKUP=/var/www/sites/jerome.tamarelle.net/backup | |
# Backup files | |
BACKUP_NAME=$(command date +"%Y-%m-%d") | |
mkdir ${BACKUP} | |
command tar -cjvf "${BACKUP}/${BACKUP_NAME}-files.tar.bz2" ${WORDPRESS} | |
# Backup database | |
DB_HOST=$(command grep "DB_HOST" ${WORDPRESS}/wp-config.php | command sed -e "s/^.*,[ ]*'\(.*\)'.*$/\1/") | |
DB_USER=$(command grep "DB_USER" ${WORDPRESS}/wp-config.php | command sed -e "s/^.*,[ ]*'\(.*\)'.*$/\1/") | |
DB_PASSWORD=$(command grep "DB_PASSWORD" ${WORDPRESS}/wp-config.php | command sed -e "s/^.*,[ ]*'\(.*\)'.*$/\1/") | |
DB_NAME=$(command grep "DB_NAME" ${WORDPRESS}/wp-config.php | command sed -e "s/^.*,[ ]*'\(.*\)'.*$/\1/") | |
command mysqldump -u ${DB_USER} --password=${DB_PASSWORD} -h ${DB_HOST} \ | |
--databases ${DB_NAME} > ${BACKUP}/database.sql | |
command tar -cjvf ${BACKUP}/${BACKUP_NAME}-database.tar.bz2 ${BACKUP}/database.sql | |
# Download WordPress | |
TMP=$(command mktemp -d) | |
command cd ${TMP} | |
command wget http://fr.wordpress.org/wordpress-${VERSION}-fr_FR.tar.gz | |
command tar xfz wordpress-${VERSION}-fr_FR.tar.gz | |
command rm -rf ${TMP}/wordpress/wp-content/ | |
# Setup .maintenance file | |
command touch .maintenance | |
# Remove old files | |
command rm -rf ${WORDPRESS}/wp-includes/ | |
command rm -rf ${WORDPRESS}/wp-admin/ | |
# Update files | |
command cp -R ${TMP}/wordpress/* ${WORDPRESS}/ | |
# Delete working files | |
command cd ${WORDPRESS} | |
command rm -rf ${TMP} | |
command rm ${BACKUP}/database.sql | |
# Clean up | |
command rm ${WORDPRESS}/.maintenance | |
command rm ${WORDPRESS}/wp-content/*/.tmp | |
command rm -rf ${WORDPRESS}/wp-content/upgrade | |
echo "Go to url/to/wordpress/wp-admin/upgrade.php" | |
# Restore the database backup | |
mysql -h ${DB_HOST} -u ${DB_USER} -p${DB_PASSWORD} ${DB_NAME} < ${BACKUP}/database.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment