# Setup environment for the backups website
function hydra_backup_environment_local_website {
- SITE="$1"
- BACKUPDIR="/var/sites/backups/site/$SITE"
+ NODE="$1"
+ SITE="$2"
+ BACKUPDIR="/var/sites/backups/site/$SITE/$NODE"
- if [ -z "$SITE" ]; then
+ if [ -z "$SITE" ] || [ -z "$NODE" ]; then
hydra_action_usage
exit 1
fi
if [ -z "$METHOD" ]; then
if [ -d "$BACKUPDIR/rsync" ]; then
echo "Assuming rsync backup method"
- BACKUPDIR="$BACKUPDIR/rsync"
+ BACKUPDIR="$BACKUPDIR/rsync/var/backups/duplicity/daily.1"
elif [ -d "$BACKUPDIR/rdiff" ]; then
echo "Assuming rdiff backup method"
- BACKUPDIR="$BACKUPDIR/rdiff"
+ BACKUPDIR="$BACKUPDIR/rdiff/var/backups/duplicity"
else
echo "Missing backup action"
exit 1
# Command line arguments
NODES="$*"
-COMMIT="f360acf0fab1d941bc7de8bec3d22aabd64f49fe"
+COMMIT="26cbb26cebd495fd6260b6af65b37fe5c8a8c00b"
# Build node list
if [ -z "$NODES" ]; then
--- /dev/null
+#!/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.
--- /dev/null
+#!/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
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/
# 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
# 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
# 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
#!/bin/bash
#
-# Pack a website.
+# Backup a site.
#
# Arguments
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
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"
# 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*
--- /dev/null
+#!/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