Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
22 changes: 20 additions & 2 deletions restic-backup.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion restic-backup.sh.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5b586ba6d0b173cdf62f0eadf8fd2d63b57cb2923d65ecff32b8111fbe400c7c restic-backup.sh
5825ecea08b3a346d7a1682b54b0602d5c028344d437bff5bb2c6f8e4ffdf35f restic-backup.sh