docker-duplicity-cron/backup.sh

41 lines
875 B
Bash
Raw Normal View History

2017-03-19 00:11:03 +00:00
#! /bin/bash
set -e
(
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
# Run pre-backup scripts
for f in /scripts/backup/before/*; do
if [ -f $f -a -x $f ]; then
bash $f
fi
done
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 \
$OPT_ARGUMENTS \
$PATH_TO_BACKUP \
2017-03-19 00:11:03 +00:00
$BACKUP_DEST
if [ -n "$CLEANUP_COMMAND" ]; then
duplicity $CLEANUP_COMMAND \
--log-file /root/duplicity.log \
--name $BACKUP_NAME \
$BACKUP_DEST
fi
# Run post-backup scripts
for f in /scripts/backup/after/*; do
if [ -f $f -a -x $f ]; then
bash $f
fi
done
) 200>/var/lock/duplicity/.duplicity.lock