2017-03-19 00:11:03 +00:00
|
|
|
#! /bin/bash
|
|
|
|
set -e
|
|
|
|
|
2019-01-28 19:44:38 +00:00
|
|
|
# Run pre-backup scripts
|
|
|
|
for f in /scripts/backup/before/*; do
|
2021-06-14 22:55:26 +00:00
|
|
|
if [ -f "$f" ] && [ -x "$f" ]; then
|
|
|
|
bash "$f"
|
2018-05-13 17:30:02 +00:00
|
|
|
fi
|
2019-01-28 19:44:38 +00:00
|
|
|
done
|
2017-03-19 00:11:03 +00:00
|
|
|
|
2021-06-14 22:55:26 +00:00
|
|
|
# shellcheck disable=SC2086
|
2018-07-24 15:38:22 +00:00
|
|
|
restic \
|
2021-06-14 22:55:26 +00:00
|
|
|
-r "$BACKUP_DEST" \
|
2018-07-24 15:38:22 +00:00
|
|
|
$OPT_ARGUMENTS \
|
|
|
|
backup \
|
2018-08-19 02:12:31 +00:00
|
|
|
"$PATH_TO_BACKUP"
|
2017-03-19 00:11:03 +00:00
|
|
|
|
2018-07-24 15:38:22 +00:00
|
|
|
if [ -n "$CLEANUP_COMMAND" ]; then
|
2021-06-14 22:55:26 +00:00
|
|
|
# Clean up old snapshots via provided policy
|
|
|
|
# shellcheck disable=SC2086
|
2018-07-24 15:38:22 +00:00
|
|
|
restic \
|
2021-06-14 22:55:26 +00:00
|
|
|
-r "$BACKUP_DEST" \
|
2018-07-24 15:38:22 +00:00
|
|
|
forget \
|
|
|
|
$CLEANUP_COMMAND
|
2021-06-14 22:55:26 +00:00
|
|
|
|
|
|
|
# Verify that nothing is corrupted
|
|
|
|
restic check -r "$BACKUP_DEST"
|
2018-07-24 15:38:22 +00:00
|
|
|
fi
|
2018-05-13 17:30:02 +00:00
|
|
|
|
2019-01-28 19:44:38 +00:00
|
|
|
# Run post-backup scripts
|
|
|
|
for f in /scripts/backup/after/*; do
|
2021-06-14 22:55:26 +00:00
|
|
|
if [ -f "$f" ] && [ -x "$f" ]; then
|
|
|
|
bash "$f"
|
2018-05-13 17:30:02 +00:00
|
|
|
fi
|
2019-01-28 19:44:38 +00:00
|
|
|
done
|