Skip to content

Commit 59d76c3

Browse files
authored
Merge pull request #1 from buildplan/show_snapshots
Show snapshots
2 parents 4c0138e + 74d21ae commit 59d76c3

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ This script automates encrypted, deduplicated backups of local directories to a
3333
- `sudo ./restic-backup.sh --restore` - Start the interactive restore wizard.
3434
- `sudo ./restic-backup.sh --forget` - Manually apply the retention policy and prune old data.
3535
- `sudo ./restic-backup.sh --diff` - Show a summary of changes between the last two snapshots.
36+
- `sudo ./restic-backup.sh --snapshots` - List all available snapshots in the repository.
3637
- `sudo ./restic-backup.sh --init` - (One-time setup) Initialize the remote repository.
3738
- `sudo ./restic-backup.sh --help` - Displays help and all the flags.
3839

restic-backup.sh

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
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

77
set -euo pipefail
88
umask 077
99

1010
# --- Script Constants ---
11-
SCRIPT_VERSION="0.17"
11+
SCRIPT_VERSION="0.18"
1212
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
1313
CONFIG_FILE="${SCRIPT_DIR}/restic-backup.conf"
1414
LOCK_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

275277
log_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+
358371
send_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

restic-backup.sh.sha256

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8d77c866b4d9bfe733ee699c49b55f301f425eae15bcf4715d6a469a5a540427 restic-backup.sh
1+
42dafacdeb4fd78a0f941eacb0da697bb4c9e7a7834f44c4d523353ad7a570ce restic-backup.sh

0 commit comments

Comments
 (0)