diff --git a/README.md b/README.md index 7880719..f0e5d09 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ This script automates encrypted, deduplicated backups of local directories to a - `sudo ./restic-backup.sh --restore` - Start the interactive restore wizard. - `sudo ./restic-backup.sh --forget` - Manually apply the retention policy and prune old data. - `sudo ./restic-backup.sh --diff` - Show a summary of changes between the last two snapshots. + - `sudo ./restic-backup.sh --stats` - Display repository size, file counts, and stats. - `sudo ./restic-backup.sh --unlock` - Forcibly remove stale locks from the repository. - `sudo ./restic-backup.sh --snapshots` - List all available snapshots in the repository. - `sudo ./restic-backup.sh --snapshots-delete` - Permanently delete specific snapshots. diff --git a/restic-backup.sh b/restic-backup.sh index 724db1b..7e452e5 100644 --- a/restic-backup.sh +++ b/restic-backup.sh @@ -1,14 +1,14 @@ #!/usr/bin/env bash # ================================================================= -# Restic Backup Script v0.27 - 2025.09.12 +# Restic Backup Script v0.28 - 2025.09.20 # ================================================================= set -euo pipefail umask 077 # --- Script Constants --- -SCRIPT_VERSION="0.27" +SCRIPT_VERSION="0.28" SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) CONFIG_FILE="${SCRIPT_DIR}/restic-backup.conf" LOCK_FILE="/tmp/restic-backup.lock" @@ -247,6 +247,7 @@ display_help() { printf " ${C_GREEN}%-20s${C_RESET} %s\n" "--diff" "Show a summary of changes between the last two snapshots." printf " ${C_GREEN}%-20s${C_RESET} %s\n" "--snapshots" "List all available snapshots in the repository." printf " ${C_GREEN}%-20s${C_RESET} %s\n" "--snapshots-delete" "Interactively select and permanently delete specific snapshots." + printf " ${C_GREEN}%-20s${C_RESET} %s\n" "--stats" "Display repository size, file counts, and stats." printf " ${C_GREEN}%-20s${C_RESET} %s\n" "--check" "Verify repository integrity by checking a subset of data." printf " ${C_GREEN}%-20s${C_RESET} %s\n" "--check-full" "Run a FULL, slow check verifying all repository data." printf " ${C_GREEN}%-20s${C_RESET} %s\n" "--forget" "Manually apply the retention policy and prune old data." @@ -626,6 +627,19 @@ init_repository() { fi } +run_stats() { + echo -e "${C_BOLD}--- Displaying Repository Statistics ---${C_RESET}" + log_message "Displaying repository statistics" + if restic stats 2>&1 | tee -a "$LOG_FILE"; then + log_message "Successfully displayed repository stats" + echo -e "${C_GREEN}✅ Statistics displayed successfully.${C_RESET}" + else + log_message "ERROR: Failed to retrieve repository statistics" + echo -e "${C_RED}❌ Failed to retrieve repository statistics. Check connection and credentials.${C_RESET}" >&2 + return 1 + fi +} + run_backup() { local start_time=$(date +%s) echo -e "${C_BOLD}--- Starting Backup ---${C_RESET}" @@ -937,6 +951,10 @@ case "${1:-}" in run_preflight_checks "backup" "quiet" run_snapshots_delete ;; + --stats) + run_preflight_checks "backup" "quiet" + run_stats + ;; --unlock) run_preflight_checks "unlock" "quiet" run_unlock diff --git a/restic-backup.sh.sha256 b/restic-backup.sh.sha256 index 7224e16..7686d7f 100644 --- a/restic-backup.sh.sha256 +++ b/restic-backup.sh.sha256 @@ -1 +1 @@ -5b586ba6d0b173cdf62f0eadf8fd2d63b57cb2923d65ecff32b8111fbe400c7c restic-backup.sh +5825ecea08b3a346d7a1682b54b0602d5c028344d437bff5bb2c6f8e4ffdf35f restic-backup.sh