2017-03-19 00:11:03 +00:00
|
|
|
#! /bin/bash
|
|
|
|
set -e
|
|
|
|
|
2018-05-13 17:30:02 +00:00
|
|
|
(
|
|
|
|
if ! flock -x -w $FLOCK_WAIT 200 ; then
|
|
|
|
echo 'ERROR: Could not obtain lock. Exiting.'
|
|
|
|
exit 1
|
|
|
|
fi
|
2017-03-19 00:11:03 +00:00
|
|
|
|
2018-09-28 00:32:55 +00:00
|
|
|
# Run pre-backup scripts
|
|
|
|
for f in /scripts/backup/before/*; do
|
|
|
|
if [ -f $f -a -x $f ]; then
|
|
|
|
bash $f
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2018-05-13 17:30:02 +00:00
|
|
|
duplicity \
|
|
|
|
$1 \
|
|
|
|
--asynchronous-upload \
|
2017-03-19 00:11:03 +00:00
|
|
|
--log-file /root/duplicity.log \
|
2017-06-29 06:28:48 +00:00
|
|
|
--name $BACKUP_NAME \
|
2018-05-13 17:30:02 +00:00
|
|
|
$OPT_ARGUMENTS \
|
|
|
|
$PATH_TO_BACKUP \
|
2017-03-19 00:11:03 +00:00
|
|
|
$BACKUP_DEST
|
2018-05-13 17:30:02 +00:00
|
|
|
|
|
|
|
if [ -n "$CLEANUP_COMMAND" ]; then
|
|
|
|
duplicity $CLEANUP_COMMAND \
|
|
|
|
--log-file /root/duplicity.log \
|
|
|
|
--name $BACKUP_NAME \
|
|
|
|
$BACKUP_DEST
|
|
|
|
fi
|
2018-09-28 00:32:55 +00:00
|
|
|
|
|
|
|
# Run post-backup scripts
|
|
|
|
for f in /scripts/backup/after/*; do
|
|
|
|
if [ -f $f -a -x $f ]; then
|
|
|
|
bash $f
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2018-05-13 17:30:02 +00:00
|
|
|
) 200>/var/lock/duplicity/.duplicity.lock
|