aboutsummaryrefslogtreecommitdiff
path: root/share/hydractl/backup-site
diff options
context:
space:
mode:
Diffstat (limited to 'share/hydractl/backup-site')
-rwxr-xr-xshare/hydractl/backup-site25
1 files changed, 13 insertions, 12 deletions
diff --git a/share/hydractl/backup-site b/share/hydractl/backup-site
index 68b2e4c..437d3e4 100755
--- a/share/hydractl/backup-site
+++ b/share/hydractl/backup-site
@@ -28,6 +28,7 @@ DATE="`date +%Y%m%d`"
DEST_BASE="$SITES/backups/site"
DEST_BASE_SITE="$DEST_BASE/$SITE"
DEST="$DEST_BASE_SITE/`facter hostname`/$DATE"
+DATABASE="`hydra_database_name $SITE`"
# Syntax check.
if [ -z "$SITE" ]; then
@@ -116,18 +117,18 @@ if [ -d "$LOCATION" ]; then
fi
# Backup database
-if [ -d "/var/lib/mysql/$SITE" ]; then
- if [ -e "$SITE.sql.bz2" ]; then
- echo "File $SITE.sql.bz2 already exists, skipping..."
+if [ -d "/var/lib/mysql/$DATABASE" ]; then
+ if [ -e "$DATABASE" ]; then
+ echo "File $DATABASE already exists, skipping..."
else
- echo "Backing up database $SITE..."
- mysqldump $SITE > $SITE.sql
- bzip2 $SITE.sql
- rm -f $SITE.sql
- md5sum $SITE.sql.bz2 > $SITE.sql.bz2.md5
- sha1sum $SITE.sql.bz2 > $SITE.sql.bz2.sha1
- chown root.$BACKUPS_GROUP $SITE.sql*
- chmod 640 $SITE.sql*
- echo "Saved $DEST/$SITE.sql.bz2"
+ echo "Backing up database $DATABASE..."
+ mysqldump $DATABASE > $DATABASE.sql
+ bzip2 $DATABASE.sql
+ rm -f $DATABASE.sql
+ md5sum $DATABASE.sql.bz2 > $DATABASE.sql.bz2.md5
+ sha1sum $DATABASE.sql.bz2 > $DATABASE.sql.bz2.sha1
+ chown root.$BACKUPS_GROUP $DATABASE.sql*
+ chmod 640 $DATABASE.sql*
+ echo "Saved $DEST/$DATABASE.sql.bz2"
fi
fi