上一篇文章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