Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manually creating a lock #2166

Open
sorcix opened this issue Feb 11, 2019 · 6 comments
Open

Manually creating a lock #2166

sorcix opened this issue Feb 11, 2019 · 6 comments

Comments

@sorcix
Copy link

sorcix commented Feb 11, 2019

Output of restic version

restic 0.9.4 compiled with go1.11.4 on darwin/amd64

What should restic do differently? Which functionality do you think we should add?

Add the ability to manually create a write lock.

What are you trying to do?

My restic repository is stored both in the cloud (master) and on a USB disk drive (backup copy). For performance reasons I run the check/prune commands on the USB drive, then upload the changes using rclone. This means that while I'm running check/prune the cloud copy is not locked. It would be great if there was a way to manually create a lock.

@sorcix
Copy link
Author

sorcix commented Feb 11, 2019

Looks like most of the code is already there in the cmd/restic package and I just need to create a new command to make use of it. If it's ok to have this feature I could create a PR to add it.

@ProactiveServices
Copy link
Contributor

I'd definitely make use of this in a similar use-case.

@MichaelEischer
Copy link
Member

If we implement this, I think the command should be modeled after borg [common options] with-lock [options] REPOSITORY COMMAND [ARGS...]. Simply creating a lock file won't be sufficient as it must be refreshed from time to time.

@MichaelEischer MichaelEischer removed the state: need direction need key decisions or input from core developers label Aug 20, 2022
@alyandon
Copy link

I have a similar use case for a feature like this. I'm in the process of migrating from borg to restic and I need to sync my repos to off-site storage for DR purposes and would like to protect against restic updating the repo while the sync process is running. Currently, with borg - the sync process can be run via borg with-lock <repo> <command> which locks the repository for exclusive access for the duration of the operation.

@MichaelEischer
Copy link
Member

restic never modifies a file after writing it (the full lifecycle is: write temp file, rename to final name, read n times, delete). You can copy a repository while restic is active, by first syncing the snapshots directory, then the index and finally data (first copy new files, then remove deleted ones). If the sync process does not complete, the some new snapshots may not be readable, however, existing snapshots won't be affected. (It might be necessary to run restic repair index though)

@alyandon
Copy link

alyandon commented Oct 4, 2023

That is certainly good information to know!

I've already cobbled together a somewhat working solution via flock for the time being but that also involves writing a wrapper script to check for the lock (e.g. wrapper script named restic - actual restic binary as restic-bin) to get everything working.

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

No branches or pull requests

4 participants