|
|
@ -4,39 +4,63 @@
|
|
|
|
# FUNCTION SWITCHES #
|
|
|
|
# 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'
|
|
|
|
readonly DEBUG='no'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## For use with NTFY.
|
|
|
|
|
|
|
|
## If set 'yes' will need to set NTFY_URL further below
|
|
|
|
readonly NTFY_NOTIFICATIONS='no'
|
|
|
|
readonly NTFY_NOTIFICATIONS='no'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## For running the rsync script.
|
|
|
|
|
|
|
|
## Will ened to set the rsync vars further below
|
|
|
|
readonly RSYNC_BACKUP='no'
|
|
|
|
readonly RSYNC_BACKUP='no'
|
|
|
|
readonly LOCAL_RESTIC_BACKUP='no'
|
|
|
|
|
|
|
|
readonly LOCAL_RESTIC_BACKUP_CLEAN='no'
|
|
|
|
## For running the restic script.
|
|
|
|
readonly REMOTE_RESTIC_BACKUP_CLEAN_LOCAL='no'
|
|
|
|
readonly LAN_RESTIC_BACKUP='no'
|
|
|
|
readonly REMOTE_RESTIC_BACKUP='no'
|
|
|
|
readonly LAN_RESTIC_CLEAN='no'
|
|
|
|
readonly REMOTE_RESTIC_BACKUP_CLEAN='no'
|
|
|
|
readonly AWS_RESTIC_BACKUP='no'
|
|
|
|
# Set the below 'no' if using keep last instead
|
|
|
|
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'
|
|
|
|
readonly RESTIC_CALENDAR_RETENTION='yes'
|
|
|
|
|
|
|
|
|
|
|
|
############################
|
|
|
|
############################
|
|
|
|
# LOGGING & ERROR HANDLING #
|
|
|
|
# LOGGING & ERROR HANDLING #
|
|
|
|
############################
|
|
|
|
############################
|
|
|
|
|
|
|
|
|
|
|
|
# Ensure you set the SCRIPT_DIR variable correctly as the error handling will not catch it
|
|
|
|
## Leave these vars be
|
|
|
|
# Change the LOG_RETENTION if you wish for more or less.
|
|
|
|
readonly LOG_DIR="${SCRIPT_DIR}/logs"
|
|
|
|
readonly LOG_DIR="${SCRIPT_DIR}/backupLogs"
|
|
|
|
|
|
|
|
readonly DATETIME="$(date '+%Y-%m-%d_%H:%M:%S')"
|
|
|
|
readonly DATETIME="$(date '+%Y-%m-%d_%H:%M:%S')"
|
|
|
|
readonly BACKUP_LOG="${LOG_DIR}/backupLog_"${DATETIME}".log"
|
|
|
|
readonly BACKUP_LOG="${LOG_DIR}/"${DATETIME}"_backup.log"
|
|
|
|
readonly LOG_RETENTION="14"
|
|
|
|
|
|
|
|
|
|
|
|
## 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 #
|
|
|
|
# RSYNC SCRIPT #
|
|
|
|
################
|
|
|
|
################
|
|
|
|
|
|
|
|
|
|
|
|
## Configure variables from here...
|
|
|
|
## Only uncomment and set these if RSYNC_BACKUP further above is set to 'yes'
|
|
|
|
# readonly RSYNC_SOURCE="/path/to/dir/to/backup"
|
|
|
|
|
|
|
|
# readonly RSYNC_DEST="/path/to/dir/to/backup/to"
|
|
|
|
## 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_MANIFEST="${SCRIPT_DIR}/rsyncManifest"
|
|
|
|
# readonly RSYNC_RETENTION_DAYS="7"
|
|
|
|
|
|
|
|
## ...to here
|
|
|
|
|
|
|
|
# readonly RSYNC_DEST_PATH="${RSYNC_DEST}/${DATETIME}"
|
|
|
|
# readonly RSYNC_DEST_PATH="${RSYNC_DEST}/${DATETIME}"
|
|
|
|
# readonly RSYNC_LATEST_LINK="${RSYNC_DEST}/latest"
|
|
|
|
# readonly RSYNC_LATEST_LINK="${RSYNC_DEST}/latest"
|
|
|
|
|
|
|
|
|
|
|
@ -44,19 +68,29 @@ readonly LOG_RETENTION="14"
|
|
|
|
# RESTIC SCRIPT #
|
|
|
|
# RESTIC SCRIPT #
|
|
|
|
#################
|
|
|
|
#################
|
|
|
|
|
|
|
|
|
|
|
|
## Only use the following two AWS vars if backing up to a compatible repo
|
|
|
|
## Only uncomment and set these if the relevant RESTIC vars further above are set to 'yes'
|
|
|
|
# export AWS_ACCESS_KEY_ID="KEY-IID"
|
|
|
|
|
|
|
|
# export AWS_SECRET_ACCESS_KEY="SECRET-KEY"
|
|
|
|
## Only set these if backing up to a compatible repo
|
|
|
|
## Set all the remaining variables except for the last
|
|
|
|
# export AWS_ACCESS_KEY_ID='KEY-ID'
|
|
|
|
# export RESTIC_PASSWORD="REPOSITORY-PASSWORD"
|
|
|
|
# export AWS_SECRET_ACCESS_KEY='SECRET-KEY'
|
|
|
|
# export RESTIC_REPOSITORY="PATH-TO-REPOSITORY"
|
|
|
|
|
|
|
|
# readonly RESTIC_SOURCE="/path/to/dir/to/backup"
|
|
|
|
## Set these for all restic configurations
|
|
|
|
# readonly RESTIC_RETENTION_DAYS="7"
|
|
|
|
# export RESTIC_REPOSITORY='/path/to/repo'
|
|
|
|
# readonly RESTIC_RETENTION_WEEKS="4"
|
|
|
|
# export RESTIC_PASSWORD='PASSWORD'
|
|
|
|
# readonly RESTIC_RETENTION_MONTHS="6"
|
|
|
|
# readonly RESTIC_SOURCE='/path/to/dir/to/backup'
|
|
|
|
# readonly RESTIC_RETENTION_YEARS="1"
|
|
|
|
|
|
|
|
## If you prefer a keep last retention policy, comment out the above 4 and uncomment the below and configure
|
|
|
|
## RESTIC_CALENDAR_RETENTION must be set to 'yes' for these
|
|
|
|
# readonly RESTIC_RETENTION_KEEP_LAST="2"
|
|
|
|
# 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_01="${HOSTNAME}"
|
|
|
|
# readonly RESTIC_TAG_02="TAG-02"
|
|
|
|
# readonly RESTIC_TAG_02='TAG-02'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Leave this var be
|
|
|
|
# readonly RESTIC_EXCLUDES="${SCRIPT_DIR}/resticExcludes"
|
|
|
|
# readonly RESTIC_EXCLUDES="${SCRIPT_DIR}/resticExcludes"
|