Add pre and post backup hooks

This commit is contained in:
Lucas Breton
2020-04-29 17:57:16 +02:00
committed by Tobias Kaupat
parent 23a05d88b9
commit 46df366e4c
2 changed files with 23 additions and 0 deletions

View File

@@ -19,6 +19,15 @@ Latest (experimental)
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.**
# Test the container

View File

@@ -11,6 +11,13 @@ logLast() {
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`
rm -f ${lastLogfile} ${lastMailLogfile}
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."
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