diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2012-01-04 19:48:48 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2012-01-04 19:48:48 -0200 |
commit | 2aea93cd0be52618f2bad54c97060958e82840d2 (patch) | |
tree | f0363bdbe22c44acd06861ee14b6a2883a7093de /share/hydractl/backup-copy-site | |
parent | 121eb7eb9326d2ff2f6f10095d781895cff6fb44 (diff) | |
download | hydra-2aea93cd0be52618f2bad54c97060958e82840d2.tar.gz hydra-2aea93cd0be52618f2bad54c97060958e82840d2.tar.bz2 |
Coding backup-copy-site
Diffstat (limited to 'share/hydractl/backup-copy-site')
-rwxr-xr-x | share/hydractl/backup-copy-site | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/share/hydractl/backup-copy-site b/share/hydractl/backup-copy-site index d64ac7e..8eccecd 100755 --- a/share/hydractl/backup-copy-site +++ b/share/hydractl/backup-copy-site @@ -7,9 +7,33 @@ source $APP_BASE/lib/hydra/functions || exit 1 hydra_config_load -# TODO # Basic parameters. +SITES="/var/sites" +DEST="$1" +SITE="$2" +DATE="`date +%Y%m%d`" +ORIG="$SITES/backups/site/$SITE/`facter hostname`" + # Syntax check. +if [ -z "$SITE" ]; then + hydra_action_usage + exit 1 +fi + +# Ensure we have a recent local backup. +if [ ! -d "$ORIG/$DATE" ]; then + echo "Backup for $SITE at $DATE not found, creating one..." + hydractl site-backup $SITE +fi + # Parse server name and port. -# Check restore strategy. +SERVER="`echo $DEST | cut -d : -f 1`" +PORT="`echo $DEST | cut -d : -f 2`" + +# Ensure we have a port. +if [ -z "$PORT" ]; then + PORT="22" +fi + # Sync to remote destination. +rsync -av -e "ssh -p $PORT" $ORIG/ backups@$SERVER:/$ORIG/ |