# 20261031-01 - Consolidated the two divergent 1.7 versions into a single
# script. Adopted YYYYMMDD-xx versioning scheme. Version is now
# defined once (SCRIPT_VERSION) and used in help and logs.
# Removed SFTP upload; backups always go to Restic.
# Restic snapshot details (ID, parent, tags, file/dir counts,
# data added, snapshot size, duration) are now written to the
# logs. restic backup now runs with --json and the details are
# read from its backup summary. Added required-command check.
# Temporary restic output is removed on failure or interrupt.
# 2.1.2 - Added EMAIL_TO and EMAIL_FROM variables for reports.
# 2.1.3 - Added DOCKERUSER variable for account to use for launching contaners
# 2.1.4 - Restic snapshot details (ID, parent, file/dir counts, data added,
# total size, duration) are now written to the logs.
# restic backup now runs with --json; snapshot size is read from the
# backup summary instead of parsing 'restic snapshots' table output,
# so it always refers to this run's snapshot.
# Removed dependency on bc (awk used for arithmetic).
# Added total new data uploaded to end of log.
- Added email delivery of current execution log.
- Added success/failure/interruption notifications and run-specific logs.
- Added automatic cleanup of staging directories on backup failure or interruption.
- Added cleanup_staging() helper function.
- Added CURRENT_STAGING_DIR tracking.
- Added automatic RUN_LOG cleanup during failure and interruption. Improved housekeeping to prevent orphaned staging data after unexpected termination.
- Modified to save all files to a folder tree for backup rather than creating a single monolithic archive. This will allow restic to properly manage snapshots.
- Changed exception lookup to case-insensitive