aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2012-01-04 14:32:21 -0200
committerSilvio Rhatto <rhatto@riseup.net>2012-01-04 14:32:21 -0200
commitf360acf0fab1d941bc7de8bec3d22aabd64f49fe (patch)
treeafd6f8e326996018f0c5fc81cdb2a8a6121df82f /lib
parent2cfe1c7aad93d666424379b89a27247e570d6e47 (diff)
downloadhydra-f360acf0fab1d941bc7de8bec3d22aabd64f49fe.tar.gz
hydra-f360acf0fab1d941bc7de8bec3d22aabd64f49fe.tar.bz2
Enhanced backup restoration
Diffstat (limited to 'lib')
-rw-r--r--lib/hydra/backup25
-rw-r--r--lib/hydra/misc9
2 files changed, 32 insertions, 2 deletions
diff --git a/lib/hydra/backup b/lib/hydra/backup
index a92782e..f98aa0f 100644
--- a/lib/hydra/backup
+++ b/lib/hydra/backup
@@ -1,7 +1,27 @@
#!/bin/bash
-# Setup backup environment
-function hydra_backup_environment {
+# Setup environment for backup restored from localhost
+function hydra_backup_environment_local {
+ SITE="$1"
+ BACKUPDIR="/var/sites/backups/site/$SITE"
+
+ if [ -z "$SITE" ]; then
+ hydra_action_usage
+ exit 1
+ fi
+
+ if [ ! -z "$DATE" ]; then
+ RESTOREDIR="$BACKUPDIR/$DATE"
+ else
+ RESTOREDIR="$BACKUPDIR/`date +%Y%m%d`"
+ fi
+
+ DB_DUMP_BASE="$RESTOREDIR"
+ mkdir -p $RESTOREDIR
+}
+
+# Setup environment for backup restored from remote source
+function hydra_backup_environment_remote {
NODE="$1"
METHOD="$2"
BACKUP_ROOT="/var/backups/remote"
@@ -49,5 +69,6 @@ function hydra_backup_environment {
exit 1
fi
+ DB_DUMP_BASE="$RESTOREDIR/var/backups/mysql/sqldump/"
mkdir -p $RESTOREDIR
}
diff --git a/lib/hydra/misc b/lib/hydra/misc
index 77d610d..66fa1bc 100644
--- a/lib/hydra/misc
+++ b/lib/hydra/misc
@@ -71,3 +71,12 @@ function hydra_check_user {
grep -qe "^$1:" /etc/passwd
}
+
+# Check for a group
+function hydra_check_group {
+ if [ -z "$1" ]; then
+ return 1
+ fi
+
+ grep -qe "^$1:" /etc/group
+}