summaryrefslogtreecommitdiff
path: root/share/hydractl/backup-site
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2012-01-04 18:43:33 -0200
committerSilvio Rhatto <rhatto@riseup.net>2012-01-04 18:43:33 -0200
commit3f397ff1575b79f74184302f3c3b8e549895f571 (patch)
tree345e49f8b0e146e48b9a06db73258d8e88305822 /share/hydractl/backup-site
parent26cbb26cebd495fd6260b6af65b37fe5c8a8c00b (diff)
downloadhydra-3f397ff1575b79f74184302f3c3b8e549895f571.tar.gz
hydra-3f397ff1575b79f74184302f3c3b8e549895f571.tar.bz2
Adding backup/copy sites; restoration fixes
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*