docker-duplicity-cron/restore.sh

36 lines
796 B
Bash
Raw Normal View History

2017-06-29 06:28:48 +00:00
#! /bin/bash
2020-02-14 20:12:07 +00:00
set -euf
2017-06-29 06:28:48 +00:00
(
2020-02-14 20:12:07 +00:00
if ! flock -x -w "$FLOCK_WAIT" 200 ; then
echo 'ERROR: Could not obtain lock. Exiting.'
exit 1
fi
# Run pre-restore scripts
for f in /scripts/restore/before/*; do
2020-02-14 20:12:07 +00:00
if [ -f "$f" ] && [ -x "$f" ]; then
bash "$f"
fi
done
2020-02-14 20:12:07 +00:00
# Intentionally not wrapping OPT_ARGUMENTS
# shellcheck disable=SC2086
duplicity restore \
--force \
--log-file /root/duplicity.log \
2020-02-14 20:12:07 +00:00
--name "$BACKUP_NAME" \
$OPT_ARGUMENTS \
2020-02-14 20:12:07 +00:00
"$@" \
"$BACKUP_DEST" \
"$PATH_TO_BACKUP"
# Run post-restore scripts
for f in /scripts/restore/after/*; do
2020-02-14 20:12:07 +00:00
if [ -f "$f" ] && [ -x "$f" ]; then
bash "$f"
fi
done
) 200>/var/lock/duplicity/.duplicity.lock