From e1fecf58ea1f4fde7195c77733d1c175d0ff139e Mon Sep 17 00:00:00 2001 From: capntack Date: Mon, 25 Mar 2024 00:41:02 -0500 Subject: [PATCH] Added the ability to use an includes file with restic --- templates/backupsVariablesAWSTemplate.sh | 3 +++ templates/backupsVariablesTemplate.sh | 3 +++ templates/resticTemplate.sh | 22 ++++++++++++++++++++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/templates/backupsVariablesAWSTemplate.sh b/templates/backupsVariablesAWSTemplate.sh index 4611908..9c71d07 100644 --- a/templates/backupsVariablesAWSTemplate.sh +++ b/templates/backupsVariablesAWSTemplate.sh @@ -18,6 +18,9 @@ export AWS_SECRET_ACCESS_KEY='SECRET-KEY' # readonly AWS_UPLOAD='2440' export RESTIC_PASSWORD='PASSWORD' readonly RESTIC_SOURCE='/path/to/dir/to/backup' +## If you want to backup multiple paths, comment out the above and set the below to 'yes' +## And then add each path to a separate line in the resticIncludes file +readonly RESTIC_SOURCE_FROM_FILE='no' ## RESTIC_CALENDAR_RETENTION must be set to 'yes' for these ## Remove readonly if you want different retention policies diff --git a/templates/backupsVariablesTemplate.sh b/templates/backupsVariablesTemplate.sh index 73949dc..5c17ecb 100644 --- a/templates/backupsVariablesTemplate.sh +++ b/templates/backupsVariablesTemplate.sh @@ -86,6 +86,9 @@ readonly LOG_RETENTION='30' # export RESTIC_REPOSITORY='/path/to/repo' # export RESTIC_PASSWORD='PASSWORD' # readonly RESTIC_SOURCE='/home' +## If you want to backup multiple paths, leave the above commented and set the below to 'yes' +## And then add each path to a separate line in the resticIncludes file +RESTIC_SOURCE_FROM_FILE='no' ## RESTIC_CALENDAR_RETENTION must be set to 'yes' for these ## Remove readonly if LAN_AND_AWS_RESTIC is set to 'yes' and you want different retention policies diff --git a/templates/resticTemplate.sh b/templates/resticTemplate.sh index 460c434..359df83 100644 --- a/templates/resticTemplate.sh +++ b/templates/resticTemplate.sh @@ -1,6 +1,6 @@ #!/bin/bash -if [ $AWS_RESTIC_BACKUP = 'no' ]; then +if [ $AWS_RESTIC_BACKUP = 'no' ] && [ $RESTIC_SOURCE_FROM_FILE = 'no' ]; then restic backup --verbose \ --tag "${RESTIC_TAG_01}" --tag "${RESTIC_TAG_02}" \ --exclude-caches \ @@ -8,7 +8,7 @@ if [ $AWS_RESTIC_BACKUP = 'no' ]; then "${RESTIC_SOURCE}" fi -if [ $AWS_RESTIC_BACKUP = 'yes' ]; then +if [ $AWS_RESTIC_BACKUP = 'yes' ] && [ $RESTIC_SOURCE_FROM_FILE = 'no' ]; then restic backup --verbose \ --tag "${RESTIC_TAG_01}" --tag "${RESTIC_TAG_02}" \ --exclude-caches \ @@ -16,4 +16,22 @@ if [ $AWS_RESTIC_BACKUP = 'yes' ]; then -o s3.connections="${AWS_CONNECTIONS}" \ --limit-upload "${AWS_UPLOAD}" \ "${RESTIC_SOURCE}" +fi + +if [ $AWS_RESTIC_BACKUP = 'no' ] && [ $RESTIC_SOURCE_FROM_FILE = 'yes' ]; then + restic backup --verbose \ + --files-from "${SCRIPT_DIR}"/resticIncludes \ + --tag "${RESTIC_TAG_01}" --tag "${RESTIC_TAG_02}" \ + --exclude-caches \ + --exclude-file="${RESTIC_EXCLUDES}" +fi + +if [ $AWS_RESTIC_BACKUP = 'yes' ] && [ $RESTIC_SOURCE_FROM_FILE = 'yes' ]; then + restic backup --verbose \ + --files-from "${SCRIPT_DIR}"/resticIncludes \ + --tag "${RESTIC_TAG_01}" --tag "${RESTIC_TAG_02}" \ + --exclude-caches \ + --exclude-file="${RESTIC_EXCLUDES}" \ + -o s3.connections="${AWS_CONNECTIONS}" \ + --limit-upload "${AWS_UPLOAD}" fi \ No newline at end of file