mirror of
https://github.com/lobaro/restic-backup-docker.git
synced 2026-02-17 09:23:56 +00:00
Add pre and post backup hooks
This commit is contained in:
committed by
Tobias Kaupat
parent
23a05d88b9
commit
46df366e4c
@@ -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
|
||||
|
||||
14
backup.sh
14
backup.sh
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user