11#! /bin/bash
22
33# =================================================================
4- # Restic Backup Script v0.17 - 2025.09.06
4+ # Restic Backup Script v0.18 - 2025.09.08
55# =================================================================
66
77set -euo pipefail
88umask 077
99
1010# --- Script Constants ---
11- SCRIPT_VERSION=" 0.17 "
11+ SCRIPT_VERSION=" 0.18 "
1212SCRIPT_DIR=$( cd -- " $( dirname -- " ${BASH_SOURCE[0]} " ) " & > /dev/null && pwd)
1313CONFIG_FILE=" ${SCRIPT_DIR} /restic-backup.conf"
1414LOCK_FILE=" /tmp/restic-backup.lock"
@@ -262,14 +262,16 @@ display_help() {
262262 printf " ${C_GREEN} %-20s${C_RESET} %s\n" " [no command]" " Run a standard backup and apply the retention policy."
263263 printf " ${C_GREEN} %-20s${C_RESET} %s\n" " --init" " Initialize a new restic repository (one-time setup)."
264264 printf " ${C_GREEN} %-20s${C_RESET} %s\n" " --diff" " Show a summary of changes between the last two snapshots."
265+ printf " ${C_GREEN} %-20s${C_RESET} %s\n" " --snapshots" " List all available snapshots in the repository."
265266 printf " ${C_GREEN} %-20s${C_RESET} %s\n" " --check" " Verify repository integrity by checking a subset of data."
266267 printf " ${C_GREEN} %-20s${C_RESET} %s\n" " --forget" " Manually apply the retention policy and prune old data."
267268 printf " ${C_GREEN} %-20s${C_RESET} %s\n" " --restore" " Start the interactive restore wizard."
268269 printf " ${C_GREEN} %-20s${C_RESET} %s\n" " --dry-run" " Preview backup changes without creating a new snapshot."
269270 printf " ${C_GREEN} %-20s${C_RESET} %s\n" " --test" " Validate configuration, permissions, and SSH connectivity."
270271 printf " ${C_GREEN} %-20s${C_RESET} %s\n" " --help, -h" " Display this help message."
271272 echo
272- echo -e " You can use ${C_GREEN} --verbose${C_RESET} before any command for detailed live output (e.g., 'sudo $0 --verbose --diff')."
273+ echo -e " Use ${C_GREEN} --verbose${C_RESET} before any command for detailed live output (e.g., 'sudo $0 --verbose --diff')."
274+ echo
273275}
274276
275277log_message () {
@@ -355,6 +357,17 @@ run_diff() {
355357 echo -e " ${C_GREEN} ✅ Backup summary sent.${C_RESET} "
356358}
357359
360+ run_snapshots () {
361+ echo -e " ${C_BOLD} --- Listing Snapshots ---${C_RESET} "
362+ log_message " Listing all snapshots"
363+
364+ if ! restic snapshots; then
365+ log_message " ERROR: Failed to list snapshots"
366+ echo -e " ${C_RED} ❌ Failed to list snapshots. Check repository connection and credentials.${C_RESET} " >&2
367+ return 1
368+ fi
369+ }
370+
358371send_ntfy () {
359372 local title=" $1 "
360373 local tags=" $2 "
@@ -821,6 +834,10 @@ case "${1:-}" in
821834 run_preflight_checks
822835 echo -e " ${C_GREEN} ✅ All tests passed${C_RESET} "
823836 ;;
837+ --snapshots)
838+ run_preflight_checks
839+ run_snapshots
840+ ;;
824841 --restore)
825842 run_preflight_checks " restore"
826843 run_restore
@@ -841,13 +858,12 @@ case "${1:-}" in
841858 display_help
842859 ;;
843860 * )
844- # Default action or invalid command/flag
845861 if [ -n " ${1:- } " ]; then
846862 echo -e " ${C_RED} Error: Unknown command '$1 '${C_RESET} \n" >&2
847863 display_help
848864 exit 1
849865 fi
850-
866+
851867 # Default: full backup
852868 run_preflight_checks
853869
0 commit comments