aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
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
+}