#! /bin/bash # # ======================= # WordPress Upgrade Script 0.1 # Written by Command Line Idiot # http://commandlineidiot.com # You may use, modify, and redistribute this script freely # Released: April 2008 # ======================= # ======================= # set variables # ======================= # This gets the location of the WordPress install # from the user. This is the server location, not # the URL. Make sure that it does not include the # trailing slash. If you only have one WP # install, you can simply replace the followin # lines with the location, as shown: # WPLOC="/home/USER/site.com/blog" echo 'WordPress server location, without trailing slash (ex. /var/www/mysite.com/blog)' read WPLOC # This script uses the /tmp folder to download # and unzip WordPress. If you do not have access # to the /tmp folder, change this to a location # you do have access to. Be careful! Later on, # this script will delete any existing wordpress/ # folder at this location. It's best to use a # folder that is dedicated to temporary, # non-vital data, like the /tmp folder WPNEW='/tmp' # ======================= # download latest wp # ======================= # removes any existing wordpress.zip files, or # wordpress/ folders at the temp location, # downloads latest version, unzips, and deletes # the .zip file. Can I just say, THANK YOU, THANK # YOU, THANK YOU, a thousand times thank you to # WordPress for choosing to always keep their # latest software version at a simple, consistent # location. No matter what version they're on, # you will always find it at # wordpress.org/latest.zip # # Perfect. cd $WPNEW rm -rf $WPNEW/wordpress rm -f latest.zip wget http://wordpress.org/latest.zip unzip -o latest.zip rm wordpress.zip # ======================= # backup current wp # ======================= # the current wordpress install will be backed up # to a new folder in the same location, with the # extension .bak - if that folder already exists, # it gets blowed up! rm -rf $WPLOC.bak cp -rv $WPLOC $WPLOC.bak # ======================= # the move! # ======================= # And now, finally, the new files will be copied # over into the wordpress folder, overwriting any # existing files of the same name. cp -rfv $WPNEW/wordpress/*.php $WPLOC/ cp -rfv $WPNEW/wordpress/wp-admin/* $WPLOC/wp-admin/ cp -rfv $WPNEW/wordpress/wp-includes/* $WPLOC/wp-includes/ # ======================= # all done! # ======================= exit # ======================= # some notes # ======================= # There are some things rare circumstances where # this script will not work well - if the # wp-config.php file has updates to it (as the WP # guys did between 2.3 and 2.5), those will not # be copied over. Also, the wp-content folder is # not touched during the upgrade. If you need # data from the new wp-content folder, you'll # have to transfer it manually.