Rsync can be used to automate the production releases for wordpress or any other site. I maintain two wordpress sites – one for development purpose and one for production. Both sites have their respective apache web server document root. I have used the convection devel_infoheap and prod_infoheap for the two blogs.
Here is a workflow which works nicely for me:
- Keep all your stuff (non wordpress) under version control.
- Create a push.sh bash script which take an argument “devel” or “prod”. You can keep any other ids for your develment and production sites.
- Keep this code in your sync push.sh script
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" pwd )" CONFIG=devel_ if [ "$1" == "prod" ] ; then CONFIG=prod_ fi #change it if you target machine is not same as the script machine HOST=localhost cd $DIR ## replace files/directories to sync and the target directory according to your configuration rsync -r -az ../ui/data ../ui/img $HOST:/var/www/${CONFIG}infoheap/
- You can add more files and directories to above script as and when needed.
- For pushing to devel blog site just run
push.sh devel
and for production just runpush.sh prod
. This make push process very streamlined. - For files like robots.txt I maintain two versions (devel_robots.txt and prod_robots.txt). With above convection, it is easier to sync robots.txt also using the following code in bash script
rsync -r -az ${CONFIG}robots.txt $HOST:/var/www/${CONFIG}infoheap/robots.txt
Note that since source and target file names are different here, we had to specify target file in rsync command.