上一篇文章linux 3 步升级 wordpress已经说道如何经过命令升级wordpress了。今天为了更加简便,我找了一个shell脚本。运行这个脚本,就能完成全部繁琐的升级工做。为本身偷个懒。html
脚本出处mysql
#!/bin/bash # Script Name: WordPress Upgrade Shell Script # Script URI: http://www.redbridgenet.com/wordpress/wordpress-upgrade-shell-script/ # Description: Upgrades your WordPress installation following more closely the WordPress guidelines. # Version: 1.0.0 # Author: Ed Reckers # Author URI: http://www.redbridgenet.com/ # License: GPL2 # # Usage ./upgrade.wordpress.sh # This script is meant to run 1 up from your webroot or (directory containing your wordpress installation) # # Overview of the Upgrade Process via the WordPress Codex: # # 1. 备份数据库 # 2. 备份网站文件 # 3. 停用插件 # 4. 下载更新包 # 5. 删除旧的文件目录 # 6. 更新覆盖新文件 # 7. 比较 wp-config 删除样例 # 8. 运行升级页面 # 9. 重启插件 # # 在脚本中咱们的方法 # # 1. 停用插件 # 2. 把脚本放在网站目录 # 3. 修改下面填写的mysql的帐号信息 # 4. 运行脚本 ./upgrade.wordpress.sh # 5. 比较 wp-config 删除 sample # 6. 运行 wordpress 程序 # 7. 重启插件 # The label for the backups LABEL="wpbackup.www" # Set mysql account credentials MyNAME="DATABASENAME"; MyUSER="DATABASEUSER" MyPASS="DATABASEPASS"; MyHOST="DATABASEHOST" # Directory containing your wordpress installation WEBROOT="public/" # Get a sortable date like 2011-01-01 for full backups FULLDATE="$(date +"%Y-%m-%d")" # Linux bin paths, change this if it can not be autodetected via which command MYSQLDUMP="$(which mysqldump)" TAR="$(which tar)" GZIP="$(which gzip)" WGET="$(which wget)" UNZIP="$(which unzip)" CP="$(which cp)" RM="$(which rm)" # Backup your MySQL database echo "backing up MySQL..." FILE="wpbackup.sql.$FULLDATE.gz" $MYSQLDUMP --opt -u $MyUSER -h $MyHOST -p$MyPASS $MyNAME | $GZIP -9 > $FILE # Backup your website/WordPress files echo "backing up website..." FILE="$LABEL.$FULLDATE.tar.gz" $TAR -zcpf $FILE $WEBROOT # Get the latest WordPress package echo "get WordPress package..." $WGET "http://wordpress.org/latest.zip" # Unzip the files echo "unzip WordPress package..." $UNZIP -q latest.zip; # Remove the zip file echo "remove WordPress package..." $RM latest.zip; # Delete old WordPress files (akismet & twentyten always come along) # Deleting these directories prevents depracated files from remaining echo "remove WordPress files..." $RM -Rf $WEBROOT"wp-includes" $RM -Rf $WEBROOT"wp-admin" $RM -Rf $WEBROOT"wp-content/plugins/akismet" $RM -Rf $WEBROOT"wp-content/themes/twentyten" # Copy all new files from unziped WordPress package into your installation echo "copy new WordPress files..." $CP -r wordpress/* $WEBROOT; # Remove the unzipped folder echo "cleanup unzipped WordPress package..." $RM -r wordpress/; # Output that all steps are complete echo "Wordpress Successfully Upgraded"; #exit from script execution