summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2011-09-27 14:45:36 -0300
committerSilvio Rhatto <rhatto@riseup.net>2011-09-27 14:45:36 -0300
commit1f25194c5ab63ee588fa66f09cf30f5994490455 (patch)
treefac630f43fb1c5e488f24a50f9839d7c6160e6da
parent402782207daaea438316c4ef9b38f3e5198beb03 (diff)
downloadhydra-1f25194c5ab63ee588fa66f09cf30f5994490455.tar.gz
hydra-1f25194c5ab63ee588fa66f09cf30f5994490455.tar.bz2
Renaming actions and adding backup function
-rw-r--r--lib/hydra/backup51
-rwxr-xr-xshare/hydractl/backup-restore-gitosis (renamed from share/hydractl/gitosis-restore)0
-rwxr-xr-xshare/hydractl/backup-restore-site (renamed from share/hydractl/site-restore)0
-rwxr-xr-xshare/hydractl/backup-restore-svn (renamed from share/hydractl/svn-restore)0
-rwxr-xr-xshare/hydractl/backup-site (renamed from share/hydractl/site-pack)0
-rwxr-xr-xshare/hydractl/puppet-install (renamed from share/hydractl/install-puppet)0
6 files changed, 51 insertions, 0 deletions
diff --git a/lib/hydra/backup b/lib/hydra/backup
new file mode 100644
index 0000000..17f7349
--- /dev/null
+++ b/lib/hydra/backup
@@ -0,0 +1,51 @@
+#!/bin/bash
+
+# Setup backup environment
+function hydra_backup_environment {
+ NODE="$1"
+ METHOD="$2"
+ BACKUP_ROOT="/var/backups/remote"
+ DOMAIN="`facter domain`"
+ BACKUPDIR="$BACKUP_ROOT/$NODE.$domain"
+ RESTOREDIR="$BACKUPDIR/restore/`date +%Y%m%d`"
+
+ if [ -z "$NODE" ]; then
+ hydra_action_usage
+ exit 1
+ fi
+
+ if [ ! -d "$BACKUPDIR" ]; then
+ echo "No backup found at $BACKUPDIR"
+ exit 1
+ fi
+
+ if [ -z "$METHOD" ]; then
+ if [ -d "$BACKUPDIR/rsync" ]; then
+ echo "Assuming rsync backup method"
+ BACKUPDIR="$BACKUPDIR/rsync"
+ elif [ -d "$BACKUPDIR/rdiff" ]; then
+ echo "Assuming rdiff backup method"
+ BACKUPDIR="$BACKUPDIR/rdiff"
+ else
+ echo "Missing backup action"
+ exit 1
+ fi
+ else
+ if [ "$METHOD" == "restore" ];
+ echo "Invalid backup method 'restore'"
+ exit 1
+ elif [ -d "$BACKUPDIR/$METHOD" ]; then
+ BACKUPDIR="$BACKUPDIR/$METHOD"
+ else
+ echo "Backup folder for $METHOD not found at $BACKUPDIR"
+ exit 1
+ fi
+ fi
+
+ if [ -d "$RESTOREDIR" ]; then
+ echo "Restoration folder $RESTOREDIR already exists"
+ exit 1
+ fi
+
+ mkdir -p $RESTOREDIR
+}
diff --git a/share/hydractl/gitosis-restore b/share/hydractl/backup-restore-gitosis
index e69de29..e69de29 100755
--- a/share/hydractl/gitosis-restore
+++ b/share/hydractl/backup-restore-gitosis
diff --git a/share/hydractl/site-restore b/share/hydractl/backup-restore-site
index 493fc30..493fc30 100755
--- a/share/hydractl/site-restore
+++ b/share/hydractl/backup-restore-site
diff --git a/share/hydractl/svn-restore b/share/hydractl/backup-restore-svn
index e69de29..e69de29 100755
--- a/share/hydractl/svn-restore
+++ b/share/hydractl/backup-restore-svn
diff --git a/share/hydractl/site-pack b/share/hydractl/backup-site
index 2d1175b..2d1175b 100755
--- a/share/hydractl/site-pack
+++ b/share/hydractl/backup-site
diff --git a/share/hydractl/install-puppet b/share/hydractl/puppet-install
index 0d0e141..0d0e141 100755
--- a/share/hydractl/install-puppet
+++ b/share/hydractl/puppet-install