config structure
setup script prototype
This commit is contained in:
parent
f259536a80
commit
0ea0f3f123
3
debian/install
vendored
Normal file
3
debian/install
vendored
Normal 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
8
defaults.conf
Normal 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
|
||||
@ -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)"
|
||||
|
||||
@ -1,4 +0,0 @@
|
||||
REMOUNT=false
|
||||
MOUNT_DEVICE=/dev/hdb1;
|
||||
SNAPSHOT_RW=/root/snapshot;
|
||||
EXCLUDES=/usr/local/etc/backup_exclude;
|
||||
8
remote-backup.example.conf
Normal file
8
remote-backup.example.conf
Normal 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
|
||||
1
remote-backup.example.excludes
Normal file
1
remote-backup.example.excludes
Normal file
@ -0,0 +1 @@
|
||||
mysql-log
|
||||
Loading…
x
Reference in New Issue
Block a user