From 0556a3bf965a8972356765bd20026beaed171f30 Mon Sep 17 00:00:00 2001 From: Sam Scholten Date: Thu, 11 Sep 2025 16:24:58 +1000 Subject: unique Restic repository paths per host --- Makefile | 13 +++++++++---- README.md | 5 +++-- setup.sh | 6 ++++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 017841a..e6d4f5e 100644 --- a/Makefile +++ b/Makefile @@ -181,7 +181,9 @@ test-remote-teardown: @rm -rf /tmp/drestic-recovery-restore @echo "Test environment cleaned up!" @echo "Note: Test snapshots remain in your MEGA repository. Clean manually if needed:" - @echo " restic forget --repo rclone:backup_remote:/restic_backups --tag daily --prune" + @echo " # The repository path is unique per host. Find it in ~/.config/restic/env" + @echo " # Example for a host named 'my-server':" + @echo " restic forget --repo rclone:backup_remote:/drestic_backups_my-server --tag daily --prune" # Test file recovery using existing test data test-remote-recovery: @@ -321,9 +323,11 @@ recover: @echo " System scope: make snapshots-system" @echo "" @echo "Step 2: Mount backup as filesystem (easiest method)" + @echo " # The repository path is unique per host (e.g., drestic_backups_my-server)." + @echo " # Find your exact path in the 'env' file (~/.config/restic/env or /root/.restic_env)." @echo " mkdir ~/restore" - @echo " User scope: RESTIC_PASSWORD_FILE=~/.config/restic/password restic mount ~/restore --repo rclone:backup_remote:/restic_backups" - @echo " System scope: sudo RESTIC_PASSWORD_FILE=/root/.restic_password restic mount ~/restore --repo rclone:backup_remote:/restic_backups" + @echo " User scope: RESTIC_PASSWORD_FILE=~/.config/restic/password restic mount ~/restore --repo rclone:backup_remote:/drestic_backups_my-server" + @echo " System scope: sudo RESTIC_PASSWORD_FILE=/root/.restic_password restic mount ~/restore --repo rclone:backup_remote:/drestic_backups_my-server" @echo "" @echo "Step 3: Browse files in ~/restore/ (like a normal folder)" @echo " cd ~/restore/snapshots/latest/home/username/" @@ -333,7 +337,8 @@ recover: @echo " umount ~/restore" @echo "" @echo "Alternative: Restore specific files directly" - @echo " restic restore latest --target /tmp/restore --include /path/to/file --repo rclone:backup_remote:/restic_backups" + @echo " # Remember to use your unique repository path (e.g., rclone:backup_remote:/drestic_backups_my-server)" + @echo " restic restore latest --target /tmp/restore --include /path/to/file --repo rclone:backup_remote:/drestic_backups_my-server" @echo "" @echo "For more details, see README.md Recovery section" diff --git a/README.md b/README.md index 4f71505..b98c769 100644 --- a/README.md +++ b/README.md @@ -57,9 +57,10 @@ mkdir ~/restore ``` 2. Mount the backup: + The repository path is now unique per host (e.g., `drestic_backups_my-server`). Find your exact path in `~/.config/restic/env`. ```sh -# For user scope -RESTIC_PASSWORD_FILE=~/.config/restic/password restic mount ~/restore --repo rclone:backup_remote:/restic_backups +# For user scope (replace with your unique repo path) +RESTIC_PASSWORD_FILE=~/.config/restic/password restic mount ~/restore --repo rclone:backup_remote:/drestic_backups_my-server ``` 3. Browse `~/restore/snapshots/latest/` to find your files. diff --git a/setup.sh b/setup.sh index 9bc9ab4..6e9c0aa 100755 --- a/setup.sh +++ b/setup.sh @@ -233,8 +233,10 @@ configure_rclone "$MEGA_EMAIL" "$MEGA_TEMP_PASS_FILE" # Clean up temporary MEGA password file rm -f "$MEGA_TEMP_PASS_FILE" -# Define the restic repository path using the CONFIG_DIR for consistency -RESTIC_REPO="rclone:backup_remote:/restic_backups" # This path is fixed as per plan +# Define the restic repository path, making it unique per host for new installations. +# 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 initialize_restic_repo "$RESTIC_REPO" "$PASS_FILE" -- cgit v1.2.3