From eded676575e6ef6150235b71d34ec4612f1a7bfb Mon Sep 17 00:00:00 2001 From: Sam Scholten Date: Wed, 22 Oct 2025 14:12:20 +1000 Subject: Release v1.1.0: Critical multi-device fixes for small VPS instances - Fix memory swap configuration (allow 1G swap) - Add prune coordination (2-4 AM window with jitter) - Add lock retry settings for robustness - Increase rclone bandwidth to 2M - Memory limits increased to 512M --- CHANGELOG.md | 19 +++++++++++++++++++ VERSION | 1 + restic_backup.sh | 30 ++++++++++++++++++++++++++++++ restic_check.sh | 2 ++ setup.sh | 4 +++- systemd/restic-backup.service | 7 ++++--- systemd/restic-check.service | 7 ++++--- 7 files changed, 63 insertions(+), 7 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 VERSION diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..899e95c --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,19 @@ +drestic (1.1.0) stable; urgency=medium + + * Critical: Fixed memory swap configuration preventing swap usage + * Critical: Added prune coordination to prevent multi-device repository conflicts + * High: Added lock retry settings for robust multi-device operation + * Medium: Increased rclone bandwidth limit from 1M to 2M + - Prune operations now only run between 2-4 AM with random jitter + - Prune failures are warnings instead of errors + - Memory limits increased from 500M to 512M for better stability + + -- Sam Thu, 16 Jan 2025 10:00:00 -0000 + +drestic (1.0.0) stable; urgency=low + + * Initial release + * Basic multi-device backup functionality + * Support for MEGA.nz remote storage + + -- Sam Thu, 16 Jan 2025 09:00:00 -0000 \ No newline at end of file diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..1cc5f65 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.1.0 \ No newline at end of file diff --git a/restic_backup.sh b/restic_backup.sh index 831d066..e5c146e 100755 --- a/restic_backup.sh +++ b/restic_backup.sh @@ -37,12 +37,15 @@ restic backup \ --exclude-file "${CONFIG_DIR}/excludes" \ --password-file "${RESTIC_PASSWORD_FILE}" \ --option rclone.timeout=20m \ + --lock-retry-after 5m \ + --lock-stale-timeout 24h \ --tag daily || { echo "Error: Restic backup failed." >&2 notify "Restic Backup ($(whoami)@$(hostname))" "Backup phase failed!" 8 exit 1 } +<<<<<<< HEAD # Prune old snapshots echo "Applying Restic retention policy and pruning old snapshots..." restic forget \ @@ -58,6 +61,33 @@ restic forget \ notify "Restic Backup ($(whoami)@$(hostname))" "Prune phase failed!" 8 exit 1 } +======= +# Prune old snapshots - only on specific hours to avoid conflicts +HOUR=$(date +%H) +# Only prune between 2-4 AM to reduce multi-device conflicts +if [ $HOUR -ge 2 ] && [ $HOUR -lt 4 ]; then + # Add random delay to stagger multiple devices + sleep $(shuf -i 0-1800 -n 1) # 0-30 minutes random delay + echo "Applying Restic retention policy and pruning old snapshots..." + restic forget \ + --repo "${RESTIC_REPOSITORY}" \ + --password-file "${RESTIC_PASSWORD_FILE}" \ + --option rclone.timeout=20m \ + --lock-retry-after 5m \ + --lock-stale-timeout 24h \ + --keep-daily 7 \ + --keep-weekly 4 \ + --keep-monthly 6 \ + --keep-yearly 6 \ + --prune || { + echo "Warning: Restic forget/prune failed (another device might be pruning)." >&2 + notify "Restic Backup ($(whoami)@$(hostname))" "Prune phase failed!" 6 + # Don't exit on prune failure - backup was successful + } +else + echo "Skipping prune - only running between 2-4 AM to avoid multi-device conflicts" +fi +>>>>>>> 606b58c (Release v1.1.0: Critical multi-device fixes for small VPS instances) echo "--- Restic Backup finished at $(date) ---" diff --git a/restic_check.sh b/restic_check.sh index 210b11e..c8271ea 100755 --- a/restic_check.sh +++ b/restic_check.sh @@ -34,6 +34,8 @@ restic check \ --password-file "${RESTIC_PASSWORD_FILE}" \ --read-data-subset 1% \ --no-cache \ + --lock-retry-after 5m \ + --lock-stale-timeout 24h \ --verbose || { echo "Error: Restic check failed." >&2 notify "Restic Check ($(whoami)@$(hostname))" "Weekly integrity check failed!" 8 diff --git a/setup.sh b/setup.sh index 06af46b..7da38a2 100755 --- a/setup.sh +++ b/setup.sh @@ -234,6 +234,8 @@ configure_rclone "$MEGA_EMAIL" "$MEGA_TEMP_PASS_FILE" rm -f "$MEGA_TEMP_PASS_FILE" # Define the restic repository path, making it unique per host for new installations. +# This prevents multi-device conflicts and allows each device to manage its own snapshots. +# If you want to share a single repository across devices, remove the ${HOSTNAME_CLEANED} suffix. # This is backward-compatible; existing installations will have the old path in their env file. HOSTNAME_CLEANED=$(hostname | tr -cd '[:alnum:]_.-') RESTIC_REPO="rclone:backup_remote:/drestic_backups_${HOSTNAME_CLEANED}" # Path is now unique per host @@ -307,7 +309,7 @@ RCLONE_CHECKERS=1 RCLONE_TIMEOUT=7200s RCLONE_CONTIMEOUT=600s RCLONE_LOW_LEVEL_RETRIES=20 -RCLONE_BWLIMIT=1M +RCLONE_BWLIMIT=2M # Rclone memory optimization settings RCLONE_BUFFER_SIZE=4M RCLONE_USE_MMAP=false diff --git a/systemd/restic-backup.service b/systemd/restic-backup.service index 315ce0e..0e2e411 100644 --- a/systemd/restic-backup.service +++ b/systemd/restic-backup.service @@ -8,9 +8,10 @@ Type=oneshot # ExecStart path will be replaced by setup.sh during installation ExecStart=/path/to/be/replaced/restic_backup.sh # Environment variable will be set by setup.sh based on scope -# Memory limits to prevent OOM on VPS -MemoryMax=500M -MemorySwapMax=500M +Environment="HOME=/root" +# Memory limits to prevent OOM on VPS (allow swap for prune operations) +MemoryMax=512M +MemorySwapMax=1G [Install] WantedBy=timers.target diff --git a/systemd/restic-check.service b/systemd/restic-check.service index e840159..0892554 100644 --- a/systemd/restic-check.service +++ b/systemd/restic-check.service @@ -8,9 +8,10 @@ Type=oneshot # ExecStart path will be replaced by setup.sh during installation ExecStart=/path/to/be/replaced/restic_check.sh # Environment variable will be set by setup.sh based on scope -# Memory limits to prevent OOM on VPS -MemoryMax=500M -MemorySwapMax=500M +Environment="HOME=/root" +# Memory limits to prevent OOM on VPS (allow swap for safety) +MemoryMax=512M +MemorySwapMax=1G [Install] WantedBy=timers.target -- cgit v1.2.3