docker-restic-cron/scripts/backup.sh

36 lines
684 B
Bash
Raw Normal View History

2017-03-19 00:11:03 +00:00
#! /bin/bash
set -e
# 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"
fi
done
2017-03-19 00:11:03 +00:00
2021-06-14 22:55:26 +00:00
# shellcheck disable=SC2086
restic \
2021-06-14 22:55:26 +00:00
-r "$BACKUP_DEST" \
$OPT_ARGUMENTS \
backup \
"$PATH_TO_BACKUP"
2017-03-19 00:11:03 +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
restic \
2021-06-14 22:55:26 +00:00
-r "$BACKUP_DEST" \
forget \
$CLEANUP_COMMAND
2021-06-14 22:55:26 +00:00
# Verify that nothing is corrupted
restic check -r "$BACKUP_DEST"
fi
# 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"
fi
done