diff --git a/README.md b/README.md index 9aad2c4..dc74c84 100644 --- a/README.md +++ b/README.md @@ -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. +
12. Make the script executable: diff --git a/templates/backups-template.sh b/templates/backups-template.sh index 6a65017..2700a06 100644 --- a/templates/backups-template.sh +++ b/templates/backups-template.sh @@ -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}")) \ No newline at end of file