Add pre and post backup hooks

This commit is contained in:
Lucas Breton authored and Tobias Kaupat committed 2020-08-06 08:39:07 +02:00
1 parent 23a05d88b9
commit 46df366e4c
2 files changed
+23

No files matched your search

+9
View File
@@ -19,6 +19,15 @@ Latest (experimental)
docker pull lobaro/restic-backup-docker:latest docker pull lobaro/restic-backup-docker:latest
``` ```
## Hooks
If you need to execute a script before or after each backup,
you need to add your hook script in the container folder `/hooks`:
```
-v ~/home/user/hooks:/hooks
```
Call your pre backup script `pre-backup.sh` and post backup script `post-backup.sh`
Please don't hesitate to report any issue you find. **Thanks.** Please don't hesitate to report any issue you find. **Thanks.**
# Test the container # Test the container
+14
View File
@@ -11,6 +11,13 @@ logLast() {
echo "$1" >> ${lastLogfile} echo "$1" >> ${lastLogfile}
} }
if [ -f "/hooks/pre-backup.sh" ]; then
echo "Starting pre-backup script ..."
/hooks/pre-backup.sh
else
echo "Pre-backup script not found ..."
fi
start=`date +%s` start=`date +%s`
rm -f ${lastLogfile} ${lastMailLogfile} rm -f ${lastLogfile} ${lastMailLogfile}
echo "Starting Backup at $(date +"%Y-%m-%d %H:%M:%S")" echo "Starting Backup at $(date +"%Y-%m-%d %H:%M:%S")"
@@ -60,3 +67,10 @@ if [ -n "${MAILX_ARGS}" ]; then
echo "Sending mail notification FAILED. Check ${lastMailLogfile} for further information." echo "Sending mail notification FAILED. Check ${lastMailLogfile} for further information."
fi fi
fi fi
if [ -f "/hooks/post-backup.sh" ]; then
echo "Starting post-backup script ..."
/hooks/post-backup.sh
else
echo "Post-backup script not found ..."
fi