Last change
on this file since 386 was 379, checked in by Rick van der Zwet, 12 years ago |
Added port logic
|
-
Property svn:executable
set to
*
|
File size:
926 bytes
|
Rev | Line | |
---|
[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 |
|
---|
| 11 | FQDN=${1:-tyan.wirelessleiden.nl}
|
---|
| 12 | HOSTID=`echo $FQDN | awk -F "." '{print $1}'`
|
---|
| 13 |
|
---|
[379] | 14 | # Get the SSH Port and strip FQDN
|
---|
| 15 | PORT=`echo $FQDN | awk -F: '{print $2}'`
|
---|
| 16 | PORT=${PORT:-22}
|
---|
| 17 | FQDN=`echo $FQDN | awk -F: '{print $1}'`
|
---|
| 18 |
|
---|
[345] | 19 | DIRS=${2:-"configbackup mysqlbackup"}
|
---|
| 20 | BACKUP_USER=${BACKUP_USER:-${3:-backup}}
|
---|
| 21 | SSH_KEY=${4:-/root/.ssh/backup.key}
|
---|
[343] | 22 |
|
---|
| 23 | EXCLUDES=`dirname $0`/excludes
|
---|
| 24 |
|
---|
| 25 | SNAPSHOTROOT="/usr/backup/$HOSTID"
|
---|
| 26 |
|
---|
| 27 | # Deleting will be done manually to avoid whipe-outs.
|
---|
[346] | 28 | OPTS="--force --ignore-errors --archive --compress"
|
---|
[343] | 29 |
|
---|
| 30 |
|
---|
| 31 | if [ -r $EXCLUDES ]; then
|
---|
| 32 | OPTS="$OPTS --exclude-from=$EXCLUDES"
|
---|
| 33 | fi
|
---|
| 34 |
|
---|
| 35 |
|
---|
| 36 | for 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 |
|
---|
| 44 | done
|
---|
Note:
See
TracBrowser
for help on using the repository browser.