1 |
#!/bin/bash |
2 |
|
3 |
# -------------------------------------------------------- |
4 |
# simple backup script based on rsync and ssh keys |
5 |
# to provide data backup operations between |
6 |
# soulcube.psl.netfrag.org -> quepasa.netfrag.org. |
7 |
# |
8 |
# Install: |
9 |
# list/enumerate paths to backup in /etc/qbackup.list or |
10 |
# change this location below. |
11 |
# |
12 |
# Configure: |
13 |
. /etc/qbackup.conf |
14 |
# -------------------------------------------------------- |
15 |
|
16 |
if [ $1 == '-cc' ]; then |
17 |
echo "BACKUP_HOST=backup.nas.net |
18 |
BACKUP_USER=qbackup |
19 |
BACKUP_PATH=/data/BACKUP/`hostname` |
20 |
BACKUP_BWLIMIT=64 |
21 |
BACKUP_LIST=/etc/qbackup.list |
22 |
BACKUP_KEY=/etc/qbackup.key |
23 |
" > /etc/qbackup.conf |
24 |
exit |
25 |
fi |
26 |
|
27 |
# runtime config |
28 |
ssh=`which ssh` |
29 |
rsync=`which rsync` |
30 |
RSYNC_RSH="$ssh -i $BACKUP_KEY" |
31 |
sync="$rsync -azuv --bwlimit=$BACKUP_BWLIMIT" |
32 |
|
33 |
for entry in `cat $BACKUP_LIST`; do |
34 |
TARGET="$BACKUP_HOST:$BACKUP_PATH$entry" |
35 |
echo "Syncing $entry to $TARGET" |
36 |
cmd="$sync $entry $BACKUP_USER@$TARGET" |
37 |
echo `$cmd` |
38 |
done |