Back

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

#!/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 $TIMEMACHINE_DIR | tail -n 1`


echo "rsyncing $TIMEMACHINE_DIR/$LASTEST_BUNDLE/live/$HOSTNAME/$LANGUAGE_ID to $APACHE_ROOT"



rsync -av --delete $TIMEMACHINE_DIR/$LASTEST_BUNDLE/live/$HOSTNAME/$LANGUAGE_ID/ $APACHE_ROOT