summaryrefslogtreecommitdiff
path: root/share/hydractl/backup-site
diff options
context:
space:
mode:
Diffstat (limited to 'share/hydractl/backup-site')
-rwxr-xr-xshare/hydractl/backup-site21
1 files changed, 17 insertions, 4 deletions
diff --git a/share/hydractl/backup-site b/share/hydractl/backup-site
index dedf0eb..7dd9acf 100755
--- a/share/hydractl/backup-site
+++ b/share/hydractl/backup-site
@@ -2,7 +2,6 @@
#
# Pack a website.
#
-# TODO: check for backup user/group
# Arguments
SITES="/var/sites"
@@ -17,6 +16,20 @@ if [ -z "$SITE" ]; then
exit 1
fi
+# Set backups user.
+if hydra_check_user backups; then
+ $BACKUPS_USER="backups"
+else
+ $BACKUPS_USER="root"
+fi
+
+# Set backups group.
+if hydra_check_group backups; then
+ $BACKUPS_GROUP="backups"
+else
+ $BACKUPS_GROUP="root"
+fi
+
# Create folder
mkdir -p $DEST
cd $DEST
@@ -25,7 +38,7 @@ cd $DEST
if [ ! -e "$SITES/backups/site/$SITE/.htpasswd" ]; then
touch $SITES/backups/site/$SITE/.htpasswd
chmod 640 $SITES/backups/site/$SITE/.htpasswd
- chown root.backups $SITES/backups/site/$SITE/.htpasswd
+ chown root.$BACKUPS_GROUP $SITES/backups/site/$SITE/.htpasswd
fi
# Access setup
@@ -44,7 +57,7 @@ if [ -d "$SITES/$SITE" ]; then
tar jcvf $PACK $SITES/$SITE
md5sum $PACK > $PACK.md5
sha1sum $PACK > $PACK.sha1
- chown root.backups $PACK*
+ chown root.$BACKUPS_GROUP $PACK*
chmod 640 $PACK*
echo "Saved $DEST/$PACK"
fi
@@ -56,7 +69,7 @@ if [ -d "/var/lib/mysql/$SITE" ]; then
bzip2 $SITE.sql
md5sum $SITE.sql.bz2 > $SITE.sql.bz2.md5
sha1sum $SITE.sql.bz2 > $SITE.sql.bz2.sha1
- chown root.backups $SITE.sql*
+ chown root.$BACKUPS_GROUP $SITE.sql*
chmod 640 $SITE.sql*
echo "Saved $DEST/$SITE.sql.bz2"
else