summaryrefslogtreecommitdiff
path: root/share/hydractl
diff options
context:
space:
mode:
Diffstat (limited to 'share/hydractl')
-rwxr-xr-xshare/hydractl/backup-copy-site28
-rwxr-xr-xshare/hydractl/backup-site4
2 files changed, 28 insertions, 4 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/
diff --git a/share/hydractl/backup-site b/share/hydractl/backup-site
index d989ee3..914e3e4 100755
--- a/share/hydractl/backup-site
+++ b/share/hydractl/backup-site
@@ -7,14 +7,14 @@
source $APP_BASE/lib/hydra/functions || exit 1
hydra_config_load
-# Arguments
+# Basic parameters.
SITES="/var/sites"
SITE="$1"
PACK="$1.tar.bz2"
DATE="`date +%Y%m%d`"
DEST="$SITES/backups/site/$SITE/`facter hostname`/$DATE"
-# Syntax check
+# Syntax check.
if [ -z "$SITE" ]; then
hydra_action_usage
exit 1