Hi
On a Linux computer I have a local repository that I backup to using something like sudo restic backup -r /backup/restic --password-file=passwordfile
. I think I was using sudo because that is needed to access all the files I want to backup, but that makes it so all files in repository are owned by root.
Now I would like to access the repository to restore from it to anther system over ssh. So I am trying to do something like this restic -r sftp://username@192.168.1.1:12345//backup/restic --password-file=passwordfile snapshots
, but that fails with an error like:
Fatal: unable to open repository at sftp://username@192.168.1.1:12345//backup/restic: ReadDir: (/backup/restic/keys): permission denied
I did some testing with a repository that I initialized over sftp and that works so it seems like the issue is the files for /backup/restic are owned and only accessible by root.
Is it ok to just change permissions on /backup/restic? Will break the backup if I do? What about future changes by local restic backup? Will that leave some files so they cannot be read by the sftp access? How do I make it so I can use both ways to access the repo and they will not break each other?
Thanks for your help.
Sure you can change the owner and group of the repository files itself. This does not affect the actual data in the repository.
Just make sure that all users that you want to can write and read the repository files.
There are also some tips in the manual: Preparing a new repository β restic 0.18.0 documentation also maybe check out Examples β restic 0.18.0 documentation and see if this works for you
1 Like
Thank you. I did see that first one but it does not apply to me unfortunately I am using version 12.1 the default with Ubnutu 22.04 (in the process of upgrading). However, I think there is an error in the instructions.
I first change all the file to my-user by running sudo chown -R :my-user /my/backup
. That is not the error but it does seem like it should say to do that. The issue I ran into was after running the command chmod -R g+r /srv/restic-repo
I am still not able to browse the repository as my-user. So I added the x permission on files withsudo chmod -R g+rX /my/backup
. But I then wanted to see if that was required so I tried to remove it sudo find /my/backup -type d -execdir chmod 740 {} +
. When trying to connect over sftp as my-user I got an the error Fatal: unable to open repository at sftp://...
so I added it back with sudo chmod -R g+rX /my/backup
.
But then I got another error
nf snapshots
repository 983c2808 opened (version 1)
created new cache in /home/montereytest/.cache/restic
Save(<lock/584529deea>) returned error, retrying after 690.561604ms: OpenFile: permission denied
Save(<lock/584529deea>) returned error, retrying after 803.683445ms: OpenFile: permission denied
So I ended up running sudo chmod -R g+rwX /backup/restic
. That seemed to work and I was able to list the snapshots.
So based on this very limited testing adding just the read permission like suggested in the documentation does not allow the snapshots to be listed and I suspect does now allow a restore either.
To access read-only repositories, you have to add the --no-lock
option to restic commands. If a command ignores that option, then it wonβt work on a read-only repository.
1 Like