Added ability to set log retention variable

main
capntack 1 year ago
parent ea317e4ff3
commit 6c8c5e59ed

@ -143,6 +143,8 @@ sudo chmod 600 /path/to/restic/password/.file
I did not note the time it took, but I want to say it was about an hour when set to `off`, and about an hour and a half for both `auto` and `max`. I personally leave it at the default of `auto`, as `max` didn't make much of a difference. But you can decide as you like for your own backups.
h. At the end of the script, just prior to the completion of the log file, there is a line that will delete logs older than (by default) 14 days. Feel free to remove this or to edit the retention variable at the top of the script to your liking.
<br>
12. Make the script executable:

@ -4,10 +4,11 @@
# VARIABLES #
#############
# Script-wide variables and commands. You only need to configure the first one.
# Script-wide variables and commands. You only need to configure the first one, and possibly the last.
readonly LOG_DIR="/path/to/log/dir"
readonly DATETIME="$(date '+%Y-%m-%d_%H:%M:%S')"
readonly BACKUP_LOG="${LOG_DIR}/backup-log_"${DATETIME}".log"
readonly LOG_RETENTION="14"
set -o errexit
set -o nounset
@ -157,5 +158,8 @@ restic check \
# TIDYING UP #
##############
# Clean up log files older than 14 days
find $LOG_DIR -mtime +"${LOG_RETENTION}" -type f -delete
# End of script message in log
echo > >(tee >(echo "$(ts "%Y-%m-%d_%H:%M:%S") Backup Script Complete" >> "${BACKUP_LOG}"))
Loading…
Cancel
Save