source: tools/snapshot-sync.sh@ 395

Last change on this file since 395 was 379, checked in by Rick van der Zwet, 12 years ago

Added port logic

  • Property svn:executable set to *
File size: 926 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
10
11FQDN=${1:-tyan.wirelessleiden.nl}
12HOSTID=`echo $FQDN | awk -F "." '{print $1}'`
13
14# Get the SSH Port and strip FQDN
15PORT=`echo $FQDN | awk -F: '{print $2}'`
16PORT=${PORT:-22}
17FQDN=`echo $FQDN | awk -F: '{print $1}'`
18
19DIRS=${2:-"configbackup mysqlbackup"}
20BACKUP_USER=${BACKUP_USER:-${3:-backup}}
21SSH_KEY=${4:-/root/.ssh/backup.key}
22
23EXCLUDES=`dirname $0`/excludes
24
25SNAPSHOTROOT="/usr/backup/$HOSTID"
26
27# Deleting will be done manually to avoid whipe-outs.
28OPTS="--force --ignore-errors --archive --compress"
29
30
31if [ -r $EXCLUDES ]; then
32 OPTS="$OPTS --exclude-from=$EXCLUDES"
33fi
34
35
36for DIR in $DIRS; do
37 TARGET=$SNAPSHOTROOT/$DIR
38 SOURCE=/usr/backup/$HOSTID/$DIR
39 mkdir -p $TARGET || exit 1
40
41 # now the actual transfer
42 rsync --rsh="ssh -i $SSH_KEY -l $BACKUP_USER" $OPTS $FQDN:$SOURCE $TARGET
43
44done
Note: See TracBrowser for help on using the repository browser.