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
|
|
|
|
2018-05-13 17:30:02 +00:00
|
|
|
(
|
2020-02-14 20:12:07 +00:00
|
|
|
if ! flock -x -w "$FLOCK_WAIT" 200 ; then
|
2018-05-13 17:30:02 +00:00
|
|
|
echo 'ERROR: Could not obtain lock. Exiting.'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-09-28 00:32:55 +00:00
|
|
|
# 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"
|
2018-09-28 00:32:55 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2020-02-14 20:12:07 +00:00
|
|
|
# Intentionally not wrapping OPT_ARGUMENTS
|
|
|
|
# shellcheck disable=SC2086
|
2018-05-13 17:30:02 +00:00
|
|
|
duplicity restore \
|
|
|
|
--force \
|
|
|
|
--log-file /root/duplicity.log \
|
2020-02-14 20:12:07 +00:00
|
|
|
--name "$BACKUP_NAME" \
|
2018-05-13 17:30:02 +00:00
|
|
|
$OPT_ARGUMENTS \
|
2020-02-14 20:12:07 +00:00
|
|
|
"$@" \
|
|
|
|
"$BACKUP_DEST" \
|
|
|
|
"$PATH_TO_BACKUP"
|
2018-09-28 00:32:55 +00:00
|
|
|
|
|
|
|
# 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"
|
2018-09-28 00:32:55 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2018-05-13 17:30:02 +00:00
|
|
|
) 200>/var/lock/duplicity/.duplicity.lock
|