|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#####################
|
|
|
|
# FUNCTION SWITCHES #
|
|
|
|
#####################
|
|
|
|
|
|
|
|
## For any function that you want to run, change from "no" to "yes"
|
|
|
|
|
|
|
|
## Update restic (restic must be installed and script must be ran as root/sudo for this to work)
|
|
|
|
readonly UPDATE='no'
|
|
|
|
|
|
|
|
## 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 need to set the rsync vars further below
|
|
|
|
readonly RSYNC_BACKUP='no'
|
|
|
|
|
|
|
|
## 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 #
|
|
|
|
############################
|
|
|
|
|
|
|
|
## Leave these vars be
|
|
|
|
readonly LOG_DIR="${SCRIPT_DIR}/logs"
|
|
|
|
readonly DATETIME="$(date '+%Y-%m-%d_%H:%M:%S')"
|
|
|
|
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 #
|
|
|
|
################
|
|
|
|
|
|
|
|
## Only uncomment and set these if RSYNC_BACKUP further above is set to 'yes'
|
|
|
|
|
|
|
|
## Set these vars
|
|
|
|
# readonly RSYNC_SOURCE='/home'
|
|
|
|
# readonly RSYNC_DEST='/path/to/dir/to/backup/to'
|
|
|
|
# readonly RSYNC_RETENTION_KEEP_LAST='7'
|
|
|
|
|
|
|
|
## Leave these vars be
|
|
|
|
# readonly RSYNC_MANIFEST="${SCRIPT_DIR}/rsyncManifest"
|
|
|
|
# readonly RSYNC_DEST_PATH="${RSYNC_DEST}/${DATETIME}"
|
|
|
|
# readonly RSYNC_LATEST_LINK="${RSYNC_DEST}/latest"
|
|
|
|
|
|
|
|
#################
|
|
|
|
# RESTIC SCRIPT #
|
|
|
|
#################
|
|
|
|
|
|
|
|
## Only uncomment and set these if the relevant RESTIC vars further above are set to 'yes'
|
|
|
|
|
|
|
|
## Frequency of progress reporting in output/log, defaulted to once per 5 minutes
|
|
|
|
# export RESTIC_PROGRESS_FPS='0.0033333333333333335'
|
|
|
|
|
|
|
|
## Only set these if backing up to a compatible repo
|
|
|
|
# export AWS_ACCESS_KEY_ID='KEY-ID'
|
|
|
|
# export AWS_SECRET_ACCESS_KEY='SECRET-KEY'
|
|
|
|
# readonly AWS_CONNECTIONS='2'
|
|
|
|
# readonly AWS_UPLOAD='2440'
|
|
|
|
|
|
|
|
## Set these for all restic configurations
|
|
|
|
# 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
|
|
|
|
# readonly RESTIC_RETENTION_DAYS='3'
|
|
|
|
# readonly RESTIC_RETENTION_WEEKS='1'
|
|
|
|
# readonly RESTIC_RETENTION_MONTHS='1'
|
|
|
|
# readonly RESTIC_RETENTION_YEARS='2'
|
|
|
|
|
|
|
|
## RESTIC_CALENDAR_RETENTION must be set to 'no' for this
|
|
|
|
## Remove readonly if LAN_AND_AWS_RESTIC is set to 'yes' and you want different retention policies
|
|
|
|
# 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='home'
|
|
|
|
|
|
|
|
## Leave this var be
|
|
|
|
# readonly RESTIC_EXCLUDES="${SCRIPT_DIR}/resticExcludes"
|