source: tools/snapshot-sync.sh@ 344

Last change on this file since 344 was 344, checked in by Rick van der Zwet, 13 years ago

Avoid potential directory disaster.

  • Property svn:executable set to *
File size: 779 bytes
Line 
1#!/bin/sh
2#
3# $Id$
4#
5# Sync the snapshot files to the local archive
6#
7# Rick van der Zwet <info@rickvanderzwet.nl>
8
9
10FQDN=${1:-tyan.wirelessleiden.nl}
11HOSTID=`echo $FQDN | awk -F "." '{print $1}'`
12
13BACKUP_USER=${BACKUP_USER:-${2:-backup}}
14SSH_KEY=${3:-/root/.ssh/backup.key}
15DIRS=${4:-"configbackup mysqlbackup"}
16
17EXCLUDES=`dirname $0`/excludes
18
19SNAPSHOTROOT="/usr/backup/$HOSTID"
20
21# Deleting will be done manually to avoid whipe-outs.
22OPTS="--force --ignore-errors --archive"
23
24
25if [ -r $EXCLUDES ]; then
26 OPTS="$OPTS --exclude-from=$EXCLUDES"
27fi
28
29
30for DIR in $DIRS; do
31 TARGET=$SNAPSHOTROOT/$DIR
32 SOURCE=/usr/backup/$HOSTID/$DIR
33 mkdir -p $TARGET || exit 1
34
35 # now the actual transfer
36 rsync --rsh="ssh -i $SSH_KEY -l $BACKUP_USER" $OPTS $FQDN:$SOURCE $TARGET
37
38done
Note: See TracBrowser for help on using the repository browser.