mirror of
https://github.com/lobaro/restic-backup-docker.git
synced 2026-04-04 04:08:51 +00:00
Merge branch 'master' into add-webhook
This commit is contained in:
@@ -119,6 +119,7 @@ The container is setup by setting [environment variables](https://docs.docker.co
|
||||
* `RESTIC_JOB_ARGS` - Optional. Allows to specify extra arguments to the back up job such as limiting bandwith with `--limit-upload` or excluding file masks with `--exclude`.
|
||||
* `AWS_ACCESS_KEY_ID` - Optional. When using restic with AWS S3 storage.
|
||||
* `AWS_SECRET_ACCESS_KEY` - Optional. When using restic with AWS S3 storage.
|
||||
* `TEAMS_WEBHOOK_URL` - Optional. If specified, the content of `/var/log/backup-last.log` is sent to your Microsoft Teams channel after each backup.
|
||||
* `MAILX_ARGS` - Optional. If specified, the content of `/var/log/backup-last.log` is sent via mail after each backup using an *external SMTP*. To have maximum flexibility, you have to specify the mail/smtp parameters by your own. Have a look at the [mailx manpage](https://linux.die.net/man/1/mailx) for further information. Example value: `-e "MAILX_ARGS=-r 'from@example.de' -s 'Result of the last restic backup run' -S smtp='smtp.example.com:587' -S smtp-use-starttls -S smtp-auth=login -S smtp-auth-user='username' -S smtp-auth-password='password' 'to@example.com'"`.
|
||||
* `OS_AUTH_URL` - Optional. When using restic with OpenStack Swift container.
|
||||
* `OS_PROJECT_ID` - Optional. When using restic with OpenStack Swift container.
|
||||
@@ -175,6 +176,10 @@ Now you can simply specify the restic repository to be an [Swift repository](htt
|
||||
|
||||
To use rclone as a backend for restic, simply add the rclone config file as a volume with `-v /absolute/path/to/rclone.conf:/root/.config/rclone/rclone.conf`.
|
||||
|
||||
Note that for some backends (Among them Google Drive and Microsoft OneDrive), rclone writes data back to the `rclone.conf` file. In this case it needs to be writable by Docker.
|
||||
|
||||
If the the container fails to write the new `rclone.conf` file with the error message `Failed to save config after 10 tries: Failed to move previous config to backup location`, add the entire `rclone` directory as volume: `-v /absolute/path/to/rclone-dir:/root/.config/rclone`.
|
||||
|
||||
# Versioning & Changelog
|
||||
|
||||
Starting from v1.3.0 versioning follows [Semantic versioning](http://semver.org/)
|
||||
|
||||
13
backup.sh
13
backup.sh
@@ -2,6 +2,7 @@
|
||||
|
||||
lastLogfile="/var/log/backup-last.log"
|
||||
lastMailLogfile="/var/log/mail-last.log"
|
||||
lastMicrosoftTeamsLogfile="/var/log/microsoft-teams-last.log"
|
||||
|
||||
copyErrorLog() {
|
||||
cp ${lastLogfile} /var/log/backup-error-last.log
|
||||
@@ -58,6 +59,18 @@ fi
|
||||
end=`date +%s`
|
||||
echo "Finished Backup at $(date +"%Y-%m-%d %H:%M:%S") after $((end-start)) seconds"
|
||||
|
||||
if [ -n "${TEAMS_WEBHOOK_URL}" ]; then
|
||||
teamsTitle="Restic Last Backup Log"
|
||||
teamsMessage=$( cat ${lastLogfile} | sed 's/"/\"/g' | sed "s/'/\'/g" | sed ':a;N;$!ba;s/\n/\n\n/g' )
|
||||
teamsReqBody="{\"title\": \"${teamsTitle}\", \"text\": \"${teamsMessage}\" }"
|
||||
sh -c "curl -H 'Content-Type: application/json' -d '${teamsReqBody}' '${TEAMS_WEBHOOK_URL}' > ${lastMicrosoftTeamsLogfile} 2>&1"
|
||||
if [ $? == 0 ]; then
|
||||
echo "Microsoft Teams notification successfully sent."
|
||||
else
|
||||
echo "Sending Microsoft Teams notification FAILED. Check ${lastMicrosoftTeamsLogfile} for further information."
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "${MAILX_ARGS}" ]; then
|
||||
sh -c "mailx -v -S sendwait ${MAILX_ARGS} < ${lastLogfile} > ${lastMailLogfile} 2>&1"
|
||||
if [ $? == 0 ]; then
|
||||
|
||||
Reference in New Issue
Block a user