summaryrefslogtreecommitdiff
path: root/share/hydractl/backup-site
diff options
context:
space:
mode:
Diffstat (limited to 'share/hydractl/backup-site')
-rwxr-xr-xshare/hydractl/backup-site13
1 files changed, 10 insertions, 3 deletions
diff --git a/share/hydractl/backup-site b/share/hydractl/backup-site
index 7dd9acf..4bbaef4 100755
--- a/share/hydractl/backup-site
+++ b/share/hydractl/backup-site
@@ -1,6 +1,6 @@
#!/bin/bash
#
-# Pack a website.
+# Backup a site.
#
# Arguments
@@ -8,7 +8,7 @@ SITES="/var/sites"
SITE="$1"
PACK="$1.tar.bz2"
DATE="`date +%Y%m%d`"
-DEST="$SITES/backups/site/$SITE/$DATE"
+DEST="$SITES/backups/site/$SITE/`facter hostname`/$DATE"
# Syntax check
if [ -z "$SITE" ]; then
@@ -16,6 +16,13 @@ if [ -z "$SITE" ]; then
exit 1
fi
+# Determine site location.
+if [ "$SITE" == "git" ] && [ "$SITE" == "svn" ]; then
+ LOCATION="/var"
+else
+ LOCATION="$SITES"
+fi
+
# Set backups user.
if hydra_check_user backups; then
$BACKUPS_USER="backups"
@@ -54,7 +61,7 @@ fi
# Backup site
if [ -d "$SITES/$SITE" ]; then
echo "Backing up site folder..."
- tar jcvf $PACK $SITES/$SITE
+ tar jcvf $PACK $LOCATION/$SITE
md5sum $PACK > $PACK.md5
sha1sum $PACK > $PACK.sha1
chown root.$BACKUPS_GROUP $PACK*