Publish a Static Copy of Your Site

Description

This is a very simple bash script that demonstrates how one can use the timemachine functionality built into dotCMS to maintain a static copy of your site or sites, either to serve as the primary copy or to serve as a DR copy of your site and content.

The script is simplistic - it is intended as an example.  It could easily be expanded upon to copy your site across hosts or even to a static CDN for high performance.

Code

${esc.hash}!/bin/sh

TIMEMACHINE_DIR=/Users/test/git/dotCMS/dotCMS/assets/timemachine
APACHE_ROOT=/Library/WebServer/Documents
LANGUAGE_ID=1
HOSTNAME=demo.dotcms.com


LASTEST_BUNDLE=`ls -1 ${esc.dollar}TIMEMACHINE_DIR | tail -n 1`


echo "rsyncing ${esc.dollar}TIMEMACHINE_DIR/${esc.dollar}LASTEST_BUNDLE/live/${esc.dollar}HOSTNAME/${esc.dollar}LANGUAGE_ID to ${esc.dollar}APACHE_ROOT"



rsync -av --delete ${esc.dollar}TIMEMACHINE_DIR/${esc.dollar}LASTEST_BUNDLE/live/${esc.dollar}HOSTNAME/${esc.dollar}LANGUAGE_ID/ ${esc.dollar}APACHE_ROOT