Update viewSnapshots

main
Anthony 2025-02-07 21:38:11 +08:00
parent 1e3cb351e8
commit a597b01b0b
2 changed files with 17 additions and 11 deletions

View File

@ -65,11 +65,13 @@ The **MB Backup Manager** is a comprehensive backup solution designed for managi
- Logs all scheduling actions - Logs all scheduling actions
4. **Repository Maintenance** (`check_repo_stats.sh`): 4. **Repository Maintenance** (`check_repo_stats.sh`):
- Retrieves repository statistics - Retrieves detailed repository statistics.
- Applies retention policies (keeps last 7 backups by default) - Applies retention policies to manage snapshot storage:
- Performs integrity checks - **Default Retention**: Keeps only the last 7 snapshots to balance storage usage and recovery needs.
- Removes stale locks - Forgotten snapshots are pruned to reclaim storage space.
- Logs to `repo_stats_YYYY-MM-DD.log` - Performs repository integrity checks to ensure data consistency and reliability.
- Automatically detects and removes stale locks to prevent repository conflicts.
- Logs all actions and results to `repo_stats_YYYY-MM-DD.log` for traceability.
5. **Repository Validation** (`check_backup_repo.sh`): 5. **Repository Validation** (`check_backup_repo.sh`):
- Validates repository integrity - Validates repository integrity

View File

@ -58,7 +58,6 @@ fetch_available_tags() {
return 0 return 0
} }
# Function: Validate repository access
# Function: Validate repository access # Function: Validate repository access
validate_repository() { validate_repository() {
log_message "Validating repository access..." log_message "Validating repository access..."
@ -74,8 +73,8 @@ validate_repository() {
if ! RESTIC_PASSWORD=$(cat "$password_file") restic -r "$backupPath" snapshots &>/dev/null; then if ! RESTIC_PASSWORD=$(cat "$password_file") restic -r "$backupPath" snapshots &>/dev/null; then
# Attempt to fix permissions automatically # Attempt to fix permissions automatically
log_message "Attempting to fix permissions for '$backupPath'..." log_message "Attempting to fix permissions for '$backupPath'..."
sudo chown -R $(whoami):$(whoami) "$backupPath" sudo chown -R "$(whoami)":"$(whoami)" "$backupPath"
sudo chmod -R u+rw "$backupPath" sudo chmod -R u+rwX "$backupPath"
# Retry repository validation # Retry repository validation
if ! RESTIC_PASSWORD=$(cat "$password_file") restic -r "$backupPath" snapshots &>/dev/null; then if ! RESTIC_PASSWORD=$(cat "$password_file") restic -r "$backupPath" snapshots &>/dev/null; then
@ -93,8 +92,8 @@ fix_permissions() {
log_message "Checking permissions for '$backupPath'..." log_message "Checking permissions for '$backupPath'..."
if [ ! -r "$backupPath" ] || [ ! -w "$backupPath" ]; then if [ ! -r "$backupPath" ] || [ ! -w "$backupPath" ]; then
log_message "Fixing permissions for '$backupPath'..." log_message "Fixing permissions for '$backupPath'..."
sudo chown -R $(whoami):$(whoami) "$backupPath" sudo chown -R "$(whoami)":"$(whoami)" "$backupPath"
sudo chmod -R u+rw "$backupPath" sudo chmod -R u+rwX "$backupPath"
fi fi
} }
@ -133,7 +132,12 @@ main() {
fi fi
# Assign input argument # Assign input argument
TAG=$1 TAG="$1"
# Map alias tags to show all snapshots
if [ "$TAG" == "full_backup" ] || [ "$TAG" == "everything" ]; then
TAG="all"
fi
# Validate environment and dependencies # Validate environment and dependencies
validate_environment validate_environment