summaryrefslogtreecommitdiff
path: root/share/hydractl
diff options
context:
space:
mode:
Diffstat (limited to 'share/hydractl')
-rwxr-xr-xshare/hydractl/backup-restore-site3
-rwxr-xr-xshare/hydractl/backup-restore-sympa28
2 files changed, 29 insertions, 2 deletions
diff --git a/share/hydractl/backup-restore-site b/share/hydractl/backup-restore-site
index e070255..3c22e52 100755
--- a/share/hydractl/backup-restore-site
+++ b/share/hydractl/backup-restore-site
@@ -161,7 +161,6 @@ fi
# Restore database
if [ ! -z "$DB_DUMP_EXT" ]; then
echo "Restoring database $SITE..."
- BASEDIR="$FOLDER"
hydra_set_tmpfile $SITE -d
cp $DB_DUMP_BASE/$SITE.sql$DB_DUMP_EXT $TMPWORK
( cd $TMPWORK && $DB_DUMP_EXTRACT $SITE.sql$DB_DUMP_EXT )
@@ -169,7 +168,7 @@ if [ ! -z "$DB_DUMP_EXT" ]; then
mysql $SITE < $TMPWORK/$SITE.sql
hydra_unset_tmpfile $TMPWORK
else
- echo "Databases should be manually restored"
+ echo "Database should be manually restored"
fi
# Ikiwiki
diff --git a/share/hydractl/backup-restore-sympa b/share/hydractl/backup-restore-sympa
index 868789d..5f13665 100755
--- a/share/hydractl/backup-restore-sympa
+++ b/share/hydractl/backup-restore-sympa
@@ -23,6 +23,7 @@ hydra_config_load
# Parameters.
DATE="`date +%Y%m%d`"
LISTS_DIR="/var/mail/virtual"
+SITE="sympa"
# Check restore strategy.
if [ "$1" == "localhost" ] || [ "$1" == "`facter hostname`" ]; then
@@ -60,6 +61,33 @@ fi
#rsync -av $RESTOREDIR/$LISTS_DIR/bounce/ $LISTS_DIR/bounce/
rsync -av --delete $RESTOREDIR/$LISTS_DIR/ $LISTS_DIR/
+DB_DUMP_BASE="$RESTOREDIR/var/backups/mysql/sqldump"
+
+# Check if there are database dumps
+if [ -f "$DB_DUMP_BASE/$SITE.sql.gz" ]; then
+ DB_DUMP_EXT=".gz"
+ DB_DUMP_EXTRACT="gunzip"
+elif [ -f "$DB_DUMP_BASE/$SITE.sql.bz2" ]; then
+ DB_DUMP_EXT=".bz2"
+ DB_DUMP_EXTRACT="bunzip2"
+elif [ -f "$DB_DUMP_BASE/$SITE.sql" ]; then
+ DB_DUMP_EXT=""
+ DB_DUMP_EXTRACT="true"
+fi
+
+# Restore database
+if [ ! -z "$DB_DUMP_EXT" ]; then
+ echo "Restoring database $SITE..."
+ hydra_set_tmpfile $SITE -d
+ cp $DB_DUMP_BASE/$SITE.sql$DB_DUMP_EXT $TMPWORK
+ ( cd $TMPWORK && $DB_DUMP_EXTRACT $SITE.sql$DB_DUMP_EXT )
+ hydra_truncate_database $SITE
+ mysql $SITE < $TMPWORK/$SITE.sql
+ hydra_unset_tmpfile $TMPWORK
+else
+ echo "Database should be manually restored"
+fi
+
# Fix permissions.
chown -R $LISTS_USER.$LISTS_GROUP $LISTS_DIR