summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2012-01-04 18:43:33 -0200
committerSilvio Rhatto <rhatto@riseup.net>2012-01-04 18:43:33 -0200
commit3f397ff1575b79f74184302f3c3b8e549895f571 (patch)
tree345e49f8b0e146e48b9a06db73258d8e88305822 /share
parent26cbb26cebd495fd6260b6af65b37fe5c8a8c00b (diff)
downloadhydra-3f397ff1575b79f74184302f3c3b8e549895f571.tar.gz
hydra-3f397ff1575b79f74184302f3c3b8e549895f571.tar.bz2
Adding backup/copy sites; restoration fixes
Diffstat (limited to 'share')
-rwxr-xr-xshare/hydra/deploy2
-rwxr-xr-xshare/hydractl/backup-copy-site15
-rwxr-xr-xshare/hydractl/backup-copy-sites26
-rwxr-xr-xshare/hydractl/backup-restore10
-rwxr-xr-xshare/hydractl/backup-restore-gitosis2
-rwxr-xr-xshare/hydractl/backup-restore-site4
-rwxr-xr-xshare/hydractl/backup-restore-svn2
-rwxr-xr-xshare/hydractl/backup-site13
-rwxr-xr-xshare/hydractl/backup-sites14
9 files changed, 78 insertions, 10 deletions
diff --git a/share/hydra/deploy b/share/hydra/deploy
index 0a8a5de..561e675 100755
--- a/share/hydra/deploy
+++ b/share/hydra/deploy
@@ -9,7 +9,7 @@ hydra_config_load
# Command line arguments
NODES="$*"
-COMMIT="f360acf0fab1d941bc7de8bec3d22aabd64f49fe"
+COMMIT="26cbb26cebd495fd6260b6af65b37fe5c8a8c00b"
# Build node list
if [ -z "$NODES" ]; then
diff --git a/share/hydractl/backup-copy-site b/share/hydractl/backup-copy-site
new file mode 100755
index 0000000..d64ac7e
--- /dev/null
+++ b/share/hydractl/backup-copy-site
@@ -0,0 +1,15 @@
+#!/bin/bash
+#
+# Copy a site backup between servers.
+#
+
+# Load.
+source $APP_BASE/lib/hydra/functions || exit 1
+hydra_config_load
+
+# TODO
+# Basic parameters.
+# Syntax check.
+# Parse server name and port.
+# Check restore strategy.
+# Sync to remote destination.
diff --git a/share/hydractl/backup-copy-sites b/share/hydractl/backup-copy-sites
new file mode 100755
index 0000000..19b41d1
--- /dev/null
+++ b/share/hydractl/backup-copy-sites
@@ -0,0 +1,26 @@
+#!/bin/bash
+#
+# Copy multiple sites.
+#
+
+# Basic parameters.
+SERVER="$1"
+
+# Syntax check.
+if [ -z "$SITE" ]; then
+ hydra_action_usage
+ exit 1
+fi
+
+# Determine sites to copy.
+if [ -z "$2" ]; then
+ sites="`ls /var/sites`"
+else
+ shift
+ sites="$*"
+fi
+
+# Copy each site.
+for site in $sites; do
+ hydractl backup-copy-site $SERVER $site
+done
diff --git a/share/hydractl/backup-restore b/share/hydractl/backup-restore
index a5bfd42..438d1a6 100755
--- a/share/hydractl/backup-restore
+++ b/share/hydractl/backup-restore
@@ -7,11 +7,17 @@
source $APP_BASE/lib/hydra/functions || exit 1
hydra_config_load
+# Syntax check.
+if [ -z "$1" ]; then
+ echo "Usage: `basename $0` <localhost|server> [rsync|rdiff]"
+ exit 1
+fi
+
# Check restore strategy.
if [ "$1" == "localhost" ]; then
- hydra_backup_environment_local $2 restore
+ hydra_backup_environment_local
else
- hydra_backup_environment_remote $1 restore
+ hydra_backup_environment_remote $*
fi
duplicity restore file:///$BACKUPDIR/ $RESTOREDIR/
diff --git a/share/hydractl/backup-restore-gitosis b/share/hydractl/backup-restore-gitosis
index f569a8e..f8b9ea3 100755
--- a/share/hydractl/backup-restore-gitosis
+++ b/share/hydractl/backup-restore-gitosis
@@ -12,7 +12,7 @@ DATE="`date +%Y%m%d`"
# Check restore strategy.
if [ "$1" == "localhost" ] || [ "$1" == "`facter hostname`" ]; then
- hydra_backup_environment_local $2 restore
+ hydra_backup_environment_local
else
hydra_backup_environment_remote $1 restore
fi
diff --git a/share/hydractl/backup-restore-site b/share/hydractl/backup-restore-site
index ae8f87a..8f10225 100755
--- a/share/hydractl/backup-restore-site
+++ b/share/hydractl/backup-restore-site
@@ -21,9 +21,9 @@ fi
# Check restore strategy.
if [ "$1" == "backups" ]; then
- hydra_backup_environment_local_website $2 restore
+ hydra_backup_environment_local_website $2 $3
elif [ "$1" == "localhost" ] || [ "$1" == "`facter hostname`" ]; then
- hydra_backup_environment_local $2 restore
+ hydra_backup_environment_local
else
hydra_backup_environment_remote $1 restore
fi
diff --git a/share/hydractl/backup-restore-svn b/share/hydractl/backup-restore-svn
index 2f15563..ad17fdf 100755
--- a/share/hydractl/backup-restore-svn
+++ b/share/hydractl/backup-restore-svn
@@ -12,7 +12,7 @@ DATE="`date +%Y%m%d`"
# Check restore strategy.
if [ "$1" == "localhost" ] || [ "$1" == "`facter hostname`" ]; then
- hydra_backup_environment_local $2 restore
+ hydra_backup_environment_local
else
hydra_backup_environment_remote $1 restore
fi
diff --git a/share/hydractl/backup-site b/share/hydractl/backup-site
index 7dd9acf..4bbaef4 100755
--- a/share/hydractl/backup-site
+++ b/share/hydractl/backup-site
@@ -1,6 +1,6 @@
#!/bin/bash
#
-# Pack a website.
+# Backup a site.
#
# Arguments
@@ -8,7 +8,7 @@ SITES="/var/sites"
SITE="$1"
PACK="$1.tar.bz2"
DATE="`date +%Y%m%d`"
-DEST="$SITES/backups/site/$SITE/$DATE"
+DEST="$SITES/backups/site/$SITE/`facter hostname`/$DATE"
# Syntax check
if [ -z "$SITE" ]; then
@@ -16,6 +16,13 @@ if [ -z "$SITE" ]; then
exit 1
fi
+# Determine site location.
+if [ "$SITE" == "git" ] && [ "$SITE" == "svn" ]; then
+ LOCATION="/var"
+else
+ LOCATION="$SITES"
+fi
+
# Set backups user.
if hydra_check_user backups; then
$BACKUPS_USER="backups"
@@ -54,7 +61,7 @@ fi
# Backup site
if [ -d "$SITES/$SITE" ]; then
echo "Backing up site folder..."
- tar jcvf $PACK $SITES/$SITE
+ tar jcvf $PACK $LOCATION/$SITE
md5sum $PACK > $PACK.md5
sha1sum $PACK > $PACK.sha1
chown root.$BACKUPS_GROUP $PACK*
diff --git a/share/hydractl/backup-sites b/share/hydractl/backup-sites
new file mode 100755
index 0000000..883566e
--- /dev/null
+++ b/share/hydractl/backup-sites
@@ -0,0 +1,14 @@
+#!/bin/bash
+#
+# Pack multiple websites.
+#
+
+if [ -z "$1" ]; then
+ sites="`ls /var/sites`"
+else
+ sites="$*"
+fi
+
+for site in $sites; do
+ hydractl backup-site $site
+done