Updated all scripts

release/full-rewrite
capntack 6 months ago
parent 226dec6163
commit 5069f24868

@ -33,7 +33,7 @@ if [ $NTFY_NOTIFICATIONS = 'yes' ]; then
-H "Filename: backupLog_"${DATETIME}".log" \
-H prio:high \
-H "Title: Backup Failed on ${HOSTNAME}" \
ntfyUser:ntfyPassword@ntfyDomain/ntfyTopic
"${NTFY_URL}"
}
fi
@ -47,28 +47,28 @@ if [ $RSYNC_BACKUP = 'yes' ]; then
fi
# If selected, run a local restic backup
if [ $LOCAL_RESTIC_BACKUP = 'yes' ]; then
. "${SCRIPT_DIR}"/rsync.sh
if [ $LAN_RESTIC_BACKUP = 'yes' ]; then
. "${SCRIPT_DIR}"/restic.sh
fi
# If selected, run a forget, prune, and check on the local restic repo after a local restic backup
if [ $LOCAL_RESTIC_BACKUP_CLEAN = 'yes' ]; then
. "${SCRIPT_DIR}"/rsync.sh
if [ $LAN_RESTIC_CLEAN = 'yes' ]; then
. "${SCRIPT_DIR}"/resticClean.sh
fi
# If selected, run a forget, prune, and check on the local restic repo before a remote restic backup
if [ $REMOTE_RESTIC_BACKUP_CLEAN_LOCAL = 'yes' ]; then
. "${SCRIPT_DIR}"/rsync.sh
# Overwrite LAN restic variables with the AWS restic variables
if [ $LAN_AND_AWS_RESTIC = 'yes' ]; then
. "${SCRIPT_DIR}"/variablesAWS.sh
fi
# If selected, run a remote restic backup
if [ $REMOTE_RESTIC_BACKUP = 'yes' ]; then
. "${SCRIPT_DIR}"/rsync.sh
if [ $AWS_RESTIC_BACKUP = 'yes' ]; then
. "${SCRIPT_DIR}"/restic.sh
fi
# If selected, run a forget, prune, and check on the remote restic repo after a remote restic backup
if [ $REMOTE_RESTIC_BACKUP_CLEAN = 'yes' ]; then
. "${SCRIPT_DIR}"/rsync.sh
if [ $AWS_RESTIC_CLEAN = 'yes' ]; then
. "${SCRIPT_DIR}"/resticClean.sh
fi
##############
@ -89,5 +89,5 @@ if [ $NTFY_NOTIFICATIONS = 'yes' ]; then
-H "Filename: backupLog_"${DATETIME}".log" \
-H prio:low \
-H "Title: Backup Succeeded on ${HOSTNAME}" \
ntfyUser:ntfyPassword@ntfyDomain/ntfyTopic
"${NTFY_URL}"
fi

@ -3,18 +3,22 @@
# Run retention policy
if [ $RESTIC_CALENDAR_RETENTION = 'yes' ]; then
restic unlock
restic forget --prune --verbose \
--tag "${RESTIC_TAG_01}","${RESTIC_TAG_02}" \
--keep-daily "${RESTIC_RETENTION_DAYS}" \
--keep-weekly "${RESTIC_RETENTION_WEEKS}" \
--keep-monthly "${RESTIC_RETENTION_MONTHS}" \
--keep-yearly "${RESTIC_RETENTION_YEARS}"
restic unlock
fi
if [ $RESTIC_CALENDAR_RETENTION = 'no' ]; then
restic unlock
restic forget --prune --verbose \
--tag "${RESTIC_TAG_01}","${RESTIC_TAG_02}" \
--keep-last "${RESTIC_RETENTION_KEEP_LAST}"
restic unlock
fi
# Verify the repo's integrity

@ -4,4 +4,6 @@ restic backup --verbose \
--tag "${RESTIC_TAG_01}" --tag "${RESTIC_TAG_02}" \
--exclude-caches \
--exclude-file="${RESTIC_EXCLUDES}" \
--exclude "${SCRIPT_DIR}"/variables.sh \
--exclude "${SCRIPT_DIR}"/variablesAWS.sh \
"${RESTIC_SOURCE}"

@ -0,0 +1,34 @@
#!/bin/bash
########################
# AWS RESTIC REPO VARS #
########################
## Only set these if LAN_AND_AWS_RESTIC is set to 'yes' in variables.sh
## Also ensure the restic vars in that file or for the LAN restic
## Only uncomment and set this var if you want it different from variables.sh
# readonly RESTIC_CALENDAR_RETENTION='yes'
## Set these for all restic configurations
export RESTIC_REPOSITORY='/path/to/repo'
export AWS_ACCESS_KEY_ID='KEY-ID'
export AWS_SECRET_ACCESS_KEY='SECRET-KEY'
export RESTIC_PASSWORD='PASSWORD'
readonly RESTIC_SOURCE='/path/to/dir/to/backup'
## RESTIC_CALENDAR_RETENTION must be set to 'yes' for these
readonly RESTIC_RETENTION_DAYS='0'
readonly RESTIC_RETENTION_WEEKS='4'
readonly RESTIC_RETENTION_MONTHS='0'
readonly RESTIC_RETENTION_YEARS='0'
## RESTIC_CALENDAR_RETENTION must be set to 'no' for this
# readonly RESTIC_RETENTION_KEEP_LAST='2'
## Recommendation is to leave the first tag be, and configure the second
readonly RESTIC_TAG_01="${HOSTNAME}"
readonly RESTIC_TAG_02='TAG-02'
## Leave this var be
readonly RESTIC_EXCLUDES="${SCRIPT_DIR}/resticExcludes"

@ -4,39 +4,63 @@
# FUNCTION SWITCHES #
#####################
# For any function that you want to run, change from "no" to "yes"
## For any function that you want to run, change from "no" to "yes"
## For debugging the script
readonly DEBUG='no'
## For use with NTFY.
## If set 'yes' will need to set NTFY_URL further below
readonly NTFY_NOTIFICATIONS='no'
## For running the rsync script.
## Will ened to set the rsync vars further below
readonly RSYNC_BACKUP='no'
readonly LOCAL_RESTIC_BACKUP='no'
readonly LOCAL_RESTIC_BACKUP_CLEAN='no'
readonly REMOTE_RESTIC_BACKUP_CLEAN_LOCAL='no'
readonly REMOTE_RESTIC_BACKUP='no'
readonly REMOTE_RESTIC_BACKUP_CLEAN='no'
# Set the below 'no' if using keep last instead
## For running the restic script.
readonly LAN_RESTIC_BACKUP='no'
readonly LAN_RESTIC_CLEAN='no'
readonly AWS_RESTIC_BACKUP='no'
readonly AWS_RESTIC_CLEAN='no'
## Set to 'yes' if running a LAN_RESTIC_CLEAN prior to an AWS_RESTIC_BACKUP of the LAN repo
## If set to 'yes' set the restic vars further below for the LAN repo
## And set the AWS restic repo vars in the variables-aws.sh file
## restic retention vars set in this file will be for LAN, variables-aws.sh will have the AWS retention
## Also leave the RESTIC_TAGs and RESTIC_EXCLUDES vars commented out in this file
readonly LAN_AND_AWS_RESTIC='no'
## Set to 'no' if using RESTIC_RETENTION_KEEP_LAST further below
readonly RESTIC_CALENDAR_RETENTION='yes'
############################
# LOGGING & ERROR HANDLING #
############################
# Ensure you set the SCRIPT_DIR variable correctly as the error handling will not catch it
# Change the LOG_RETENTION if you wish for more or less.
readonly LOG_DIR="${SCRIPT_DIR}/backupLogs"
## Leave these vars be
readonly LOG_DIR="${SCRIPT_DIR}/logs"
readonly DATETIME="$(date '+%Y-%m-%d_%H:%M:%S')"
readonly BACKUP_LOG="${LOG_DIR}/backupLog_"${DATETIME}".log"
readonly LOG_RETENTION="14"
readonly BACKUP_LOG="${LOG_DIR}/"${DATETIME}"_backup.log"
## Adjust to your preferred retention
readonly LOG_RETENTION='30'
## If using, must set NTFY_NOTIFICATIONS further above to 'yes'
# readonly NTFY_URL='user:password@ntfy.tld/topic'
################
# RSYNC SCRIPT #
################
## Configure variables from here...
# readonly RSYNC_SOURCE="/path/to/dir/to/backup"
# readonly RSYNC_DEST="/path/to/dir/to/backup/to"
## Only uncomment and set these if RSYNC_BACKUP further above is set to 'yes'
## Set these vars
# readonly RSYNC_SOURCE='/path/to/dir/to/backup'
# readonly RSYNC_DEST='/path/to/dir/to/backup/to'
# readonly RSYNC_RETENTION_DAYS='7'
## Leave these vars be
# readonly RSYNC_MANIFEST="${SCRIPT_DIR}/rsyncManifest"
# readonly RSYNC_RETENTION_DAYS="7"
## ...to here
# readonly RSYNC_DEST_PATH="${RSYNC_DEST}/${DATETIME}"
# readonly RSYNC_LATEST_LINK="${RSYNC_DEST}/latest"
@ -44,19 +68,29 @@ readonly LOG_RETENTION="14"
# RESTIC SCRIPT #
#################
## Only use the following two AWS vars if backing up to a compatible repo
# export AWS_ACCESS_KEY_ID="KEY-IID"
# export AWS_SECRET_ACCESS_KEY="SECRET-KEY"
## Set all the remaining variables except for the last
# export RESTIC_PASSWORD="REPOSITORY-PASSWORD"
# export RESTIC_REPOSITORY="PATH-TO-REPOSITORY"
# readonly RESTIC_SOURCE="/path/to/dir/to/backup"
# readonly RESTIC_RETENTION_DAYS="7"
# readonly RESTIC_RETENTION_WEEKS="4"
# readonly RESTIC_RETENTION_MONTHS="6"
# readonly RESTIC_RETENTION_YEARS="1"
## If you prefer a keep last retention policy, comment out the above 4 and uncomment the below and configure
# readonly RESTIC_RETENTION_KEEP_LAST="2"
## Only uncomment and set these if the relevant RESTIC vars further above are set to 'yes'
## Only set these if backing up to a compatible repo
# export AWS_ACCESS_KEY_ID='KEY-ID'
# export AWS_SECRET_ACCESS_KEY='SECRET-KEY'
## Set these for all restic configurations
# export RESTIC_REPOSITORY='/path/to/repo'
# export RESTIC_PASSWORD='PASSWORD'
# readonly RESTIC_SOURCE='/path/to/dir/to/backup'
## RESTIC_CALENDAR_RETENTION must be set to 'yes' for these
# readonly RESTIC_RETENTION_DAYS='3'
# readonly RESTIC_RETENTION_WEEKS='1'
# readonly RESTIC_RETENTION_MONTHS='1'
# readonly RESTIC_RETENTION_YEARS='1'
## RESTIC_CALENDAR_RETENTION must be set to 'no' for this
# readonly RESTIC_RETENTION_KEEP_LAST='2'
## Recommendation is to leave the first tag be, and configure the second
# readonly RESTIC_TAG_01="${HOSTNAME}"
# readonly RESTIC_TAG_02="TAG-02"
# readonly RESTIC_TAG_02='TAG-02'
## Leave this var be
# readonly RESTIC_EXCLUDES="${SCRIPT_DIR}/resticExcludes"
Loading…
Cancel
Save