aboutsummaryrefslogtreecommitdiff
path: root/files/sync-backups
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2016-10-02 17:21:26 -0300
committerSilvio Rhatto <rhatto@riseup.net>2016-10-02 17:21:26 -0300
commit6d9d7b39bbf87b32a2e12fa6b29f463382c7027e (patch)
treece42a76278dddff07c24f8608b35255e705db1e1 /files/sync-backups
parentab184775e79a780eb2a32d67260756d8a9b4258d (diff)
downloadpuppet-backup-6d9d7b39bbf87b32a2e12fa6b29f463382c7027e.tar.gz
puppet-backup-6d9d7b39bbf87b32a2e12fa6b29f463382c7027e.tar.bz2
Move scripts to the Hydra Suite
Diffstat (limited to 'files/sync-backups')
-rwxr-xr-xfiles/sync-backups74
1 files changed, 0 insertions, 74 deletions
diff --git a/files/sync-backups b/files/sync-backups
deleted file mode 100755
index aa92754..0000000
--- a/files/sync-backups
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/bin/bash
-#
-# sync a removable volume with system backups.
-#
-
-# Parameters.
-BASENAME="`basename $0`"
-VOLUME="$1"
-MEDIA="/media/$VOLUME"
-BWLIMIT=${BWLIMIT:=32000}
-IMAGES="/var/data/crypt/"
-RSYNC="ionice -c 3 nice -n 19 rsync -avH --delete --bwlimit=$BWLIMIT"
-CP="ionice -c 3 nice -n 19 cp"
-
-# Sync backups for a node.
-function sync_backups_node {
- if [ ! -z "$NODE" ]; then
- # Get full node hostname.
- NODE_HOSTNAME="`cat /var/vservers/$NODE/etc/hostname`"
- if [ -z "$NODE_HOSTNAME" ]; then
- NODE_HOSTNAME="$NODE"
- fi
-
- # Sync local encrypted backup.
- echo "Syncing /var/vservers/$NODE/var/backups/duplicity/..."
- mkdir -p /$MEDIA/$NODE_HOSTNAME/duplicity
- $RSYNC /var/vservers/$NODE/var/backups/duplicity/ /$MEDIA/$NODE_HOSTNAME/duplicity/
-
- # Sync remote backups.
- for node in `ls /var/vservers/$NODE/var/backups/remote/`; do
- echo "Syncing /var/vservers/$NODE/var/backups/remote/$node/..."
- mkdir -p /$MEDIA/$NODE_HOSTNAME/remote/$node
- $RSYNC /var/vservers/$NODE/var/backups/remote/$node/ /$MEDIA/$NODE_HOSTNAME/remote/$node/
- done
- else
- # Sync local encrypted backup.
- echo "Syncing /var/backups/duplicity/..."
- mkdir -p /$MEDIA/$HOSTNAME/duplicity
- $RSYNC /var/backups/duplicity/ /$MEDIA/$HOSTNAME/duplicity/
-
- # Sync remote backups.
- for node in `ls /var/backups/remote/`; do
- echo "Syncing /var/backups/remote/$node/..."
- mkdir -p /$MEDIA/$HOSTNAME/remote/$node/
- $RSYNC /var/backups/remote/$node/ /$MEDIA/$HOSTNAME/remote/$node/
- done
-
- # Copy encrypted images.
- if [ -d "$IMAGES" ]; then
- for image in `find $IMAGES -name '*.img' -type f`; do
- echo "Copying image to /$MEDIA/$HOSTNAME/images/`dirname $image`"
- mkdir -p /$MEDIA/$HOSTNAME/images/`dirname $image`
- $CP $image /$MEDIA/$HOSTNAME/images/`dirname $image`
- done
- fi
- fi
-}
-
-# Parsing.
-if [ -z "$VOLUME" ]; then
- echo "usage: $BASENAME <media> [nodes]"
- exit 1
-else
- shift
-fi
-
-# Sync backups for each node.
-if [ ! -z "$*" ]; then
- for NODE in $*; do
- sync_backups_node
- done
-else
- sync_backups_node
-fi