config structure

setup script prototype
This commit is contained in:
Vincent Riquer 2010-08-31 12:28:11 +02:00
parent f259536a80
commit 0ea0f3f123
6 changed files with 42 additions and 21 deletions

3
debian/install vendored Normal file
View File

@ -0,0 +1,3 @@
remote-backup /usr/bin/
defaults /etc/remote-backup/
remote-backup.example.* /usr/share/remote-backup

8
defaults.conf Normal file
View File

@ -0,0 +1,8 @@
REMOUNT=false
MOUNT_DEVICE=none
SNAPSHOT_RW=/var/backups
REMOTE_LOCATION=""
EXCLUDES=/dev/null
DEST=""
MAX_ROTATE=7
BWLIMIT=0 # kBps

View File

@ -62,6 +62,8 @@ fi
source /etc/remote-backup.conf
echo "Debut de backup de ${REMOTE_LOCATION} vers ${SNAPSHOT_RW}/${DEST}/ a $(date)"
# ------------- the script itself --------------------------------------
# make sure we're running as root
@ -85,26 +87,26 @@ fi
# rotating snapshots of /home (fixme: this should be more general)
# step 1: delete the oldest snapshot, if it exists:
if [ -d $SNAPSHOT_RW/home/hourly.3 ]
if [ -d $SNAPSHOT_RW/$DEST/daily.${MAX_ROTATE} ]
then
$RM -rf $SNAPSHOT_RW/home/hourly.3
$RM -rf $SNAPSHOT_RW/$DEST/daily.${MAX_ROTATE}
fi
# step 2: shift the middle snapshots(s) back by one, if they exist
if [ -d $SNAPSHOT_RW/home/hourly.2 ]
then
$MV $SNAPSHOT_RW/home/hourly.2 $SNAPSHOT_RW/home/hourly.3
fi
if [ -d $SNAPSHOT_RW/home/hourly.1 ]
then
$MV $SNAPSHOT_RW/home/hourly.1 $SNAPSHOT_RW/home/hourly.2
fi
for backup_number in $(seq $((${MAX_ROTATE}-1)) -1 1)
do
if [ -d $SNAPSHOT_RW/$DEST/daily.${backup_number} ]
then
$MV $SNAPSHOT_RW/$DEST/daily.${backup_number} \
$SNAPSHOT_RW/$DEST/daily.$((${backup_number}+1))
fi
done
# step 3: make a hard-link-only (except for dirs) copy of the latest snapshot,
# if that exists
if [ -d $SNAPSHOT_RW/home/hourly.0 ]
if [ -d $SNAPSHOT_RW/$DEST/daily.0 ]
then
$CP -al $SNAPSHOT_RW/home/hourly.0 $SNAPSHOT_RW/home/hourly.1
$CP -al $SNAPSHOT_RW/$DEST/daily.0 $SNAPSHOT_RW/$DEST/daily.1
fi
# step 4: rsync from the system into the latest snapshot (notice that
@ -112,15 +114,16 @@ fi
# is unlinked first. If it were not so, this would copy over the other
# snapshot(s) too!
$RSYNC \
-va \
-a \
--delete \
--delete-excluded \
--exclude-from="$EXCLUDES" \
/home/ \
$SNAPSHOT_RW/home/hourly.0
--bwlimit=$BWLIMIT \
${REMOTE_LOCATION} \
$SNAPSHOT_RW/$DEST/daily.0
# step 5: update the mtime of hourly.0 to reflect the snapshot time
$TOUCH $SNAPSHOT_RW/home/hourly.0
# step 5: update the mtime of daily.0 to reflect the snapshot time
$TOUCH $SNAPSHOT_RW/$DEST/daily.0
# and thats it for home.
@ -134,3 +137,5 @@ then
exit
fi
fi
echo "Fin de backup de ${REMOTE_LOCATION} vers ${SNAPSHOT_RW}/${DEST}/ a $(date)"

View File

@ -1,4 +0,0 @@
REMOUNT=false
MOUNT_DEVICE=/dev/hdb1;
SNAPSHOT_RW=/root/snapshot;
EXCLUDES=/usr/local/etc/backup_exclude;

View File

@ -0,0 +1,8 @@
REMOUNT=__setbackup__REMOUT__
MOUNT_DEVICE=__setbackup__DEVICE__
SNAPSHOT_RW=__setbackup__SNAPSHOT__
REMOTE_LOCATION="__setbackup__REMOTE__
EXCLUDES=__setbackup__EXCLUDES__
DEST=__setbackup__DEST__
MAX_ROTATE=__setbackup__ROTATE__
BWLIMIT=__setbackup__BWLIMIT__ # kBps

View File

@ -0,0 +1 @@
mysql-log