Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Sep 8, 2025

When clicking "Index Snapshots" in the UI, Backrest calls restic snapshots to retrieve repository snapshot history. This operation could fail if another process had a lock on the repository, causing indexing operations to be blocked unnecessarily.

This PR adds the --no-lock flag to snapshot indexing operations, which performs a read-only operation that won't conflict with other processes using the repository.

Changes Made

  • Modified RepoOrchestrator.Snapshots() to accept variadic restic.GenericOption parameters for flexibility
  • Updated indexSnapshotsHelper() to pass the --no-lock flag when calling repo.Snapshots()
  • Added test coverage to verify the --no-lock flag functionality works correctly
  • Maintained backward compatibility for all existing callers

Technical Details

The change modifies the snapshot indexing flow:

  • IndexSnapshots API → NewOneoffIndexSnapshotsTaskindexSnapshotsHelperrepo.Snapshots(ctx, restic.WithFlags("--no-lock"))

This ensures that snapshot indexing operations use restic snapshots --json --no-lock instead of restic snapshots --json, preventing lock conflicts during repository indexing while other backup or maintenance operations are running.

Fixes #664.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@Copilot Copilot AI changed the title [WIP] Perform snapshot indexing with --no-lock to prevent issues if repo is in use when re-indexing Add --no-lock flag to snapshot indexing operations Sep 8, 2025
@Copilot Copilot AI requested a review from garethgeorge September 8, 2025 08:03
Copilot finished work on behalf of garethgeorge September 8, 2025 08:03
@@ -55,7 +55,7 @@ func indexSnapshotsHelper(ctx context.Context, st ScheduledTask, taskRunner Task
}

// collect all tracked snapshots for the plan.
snapshots, err := repo.Snapshots(ctx)
snapshots, err := repo.Snapshots(ctx, restic.WithFlags("--no-lock"))
if err != nil {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't pass this through, make it the default in the orchestrator. There probably isn't a scenario where we'd want to do this without --no-lock.

Copy link
Owner

@garethgeorge garethgeorge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Perform snapshot indexing with --no-lock to prevent issues if repo is in use when re-indexing
3 participants