source: tools/snapshot-sync.sh@ 382

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

Added port logic

  • Property svn:executable set to *
File size: 926 bytes
RevLine 
[343]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>
[379]8#
[343]9
10
11FQDN=${1:-tyan.wirelessleiden.nl}
12HOSTID=`echo $FQDN | awk -F "." '{print $1}'`
13
[379]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
[345]19DIRS=${2:-"configbackup mysqlbackup"}
20BACKUP_USER=${BACKUP_USER:-${3:-backup}}
21SSH_KEY=${4:-/root/.ssh/backup.key}
[343]22
23EXCLUDES=`dirname $0`/excludes
24
25SNAPSHOTROOT="/usr/backup/$HOSTID"
26
27# Deleting will be done manually to avoid whipe-outs.
[346]28OPTS="--force --ignore-errors --archive --compress"
[343]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
[344]39 mkdir -p $TARGET || exit 1
[343]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.