Macos backup on USB drive, restore/mount on Linux not working

Hi,

I’ve done a backup on a Macos using the following command:
restic -r /Volumes/BackupUSB/backup --verbose backup ~/Documents ~/Dropbox ~/Desktop

When I then try to mount this backup on Linux (Fedora 31), I get a message saying "
repository opened successfully, password correct" and afterwords i get the following messages:

Save(<lock/xxxxxxx> returned error, retrying after xs: OpenFile: open /run/media/user/BackupUSB/backup/locks/xxxxxxxxx: read-only filesystem

Above messages is repeated few times after existing with:

Fatal: unable to create lock in backend: OpenFile: open /run/media/user/BackupUSB/backup/locks/xxxxxxxxx: read-only file system
unable to unmount (maybe already mounted?): exit status 1: fusermount: /mnt/restic not mounted

On linux I’m trying to mount using the following command:
sudo restic -r /run/media/user/BackupUSB/backup mount /mnt/restic

I’m able to mount the repo on macos without issues. Is backing up on one OS and restoring/mount on another not working or are there any other caveats?

Restic needs write access to the repo folder so it can write the lock file while the backup is mounted

1 Like

You can try using the --no-lock option in this command, place it before the mount command.

But PLEASE NOTE that this will not lock your repository, so if you run restic on the same repo in parallel to your mount, your repository may be modified while you have it mounted.

1 Like

@uok I think you’re right. I’ll have to read more about how to solve this and make it linux-macos compatible.

@rawtaz unfortunately --no-lock didn’t help.

Thank you both!

Please clarify in what way this didn’t help? Your previously shown error messages show that restic tries to create a lock file, and fails to do so because it’s reading the repository from a read-only filesystem. I would expect this to not happen if you provide the --no-lock option to restic, so if it doesnt, please explain the symptoms :slight_smile:

I experienced the same error as I initially posted. I assume that’s because I didn’t have access to the repository at all due to file system format (Mac OS Extended (Case-sensitive, Journaled)). After changing to HFS+ I was able to mount the repository (but only as root!).

When I try to mount the repository as a non-root user, I get the following error message:

Fatal: unable to open repo at  /run/media/user/BackupUSB/backup/: ReadDir: open  /run/media/user/BackupUSB/backup/keys: permission denied
unable to unmount (maybe already unmounted?): exit status 1: fusermount: entry for /mnt/restic-dir not found ion /etc/mtab

This is not restic; it’s to do with how Unix file systems fundamentally assume there’s no such thing as an external drive.

You see, permissions are stored based on numeric user ids. There is no connection between ids and user names between systems. On a single user Linux system, that single user is usually UID 1000. On a Mac, it seems the default user is UID 501. It is, however, by no means safe for the OS to assume that these numbers should be mapped together - so it doesn’t.

This kind of mismatch is one of the reasons the vastly simpler FAT filesystems are generally preferred for external media.

1 Like

@odin, very useful insight. Much appreciated.

I don’t have much experience with cross-platform backups nor with different filesystems for that matter so this is a all a bit new to me. What you wrote does make sense.

I’m running another backup via S3 and will also give FAT filesystem a go with the external media. I will report back my experience in case anyone bumps into this in the future.

Which version of restic is that? What does restic version print? The --no-lock support for the mount command was added in 0.10.0.

1 Like

Gotcha, I have v0.9.6. This seems to be the latest version available on Fedora - I’ve checked yum and dnf.

There’s no need to use lagging behind packaging systems, restic is just a single binary you can download from the official releases page on GitHub.

1 Like

I’ve formatted my USB drive to exFAT and made a backup. Still experiencing same behavior as before. S3 backup is still in progress.

Issue 1:
Can only mount as root and browse through the directories/files as a root user and not as a non-root user.

Issue 2:
Doing a restore created a directory with root user and following permissions (drwx---------). When I try to cd into the directory using sudo I can’t, to explain in more detail: if I’m in ~/ dir and the restored snapshot is in ~/restored/ and I do cd ~/restored I end up being in the ~/ directory and not in ~/restored). I cant hower do ls inside any level of the the ~/restored directory as a root user.

What I wish to achieve is to restore a backup into a directory and have a non-root user access to those files as if they were created on the computer. Am I missing something - should every time you do a restore on a different computer from the one where the backup got created we run some sort of “post-restore” command to make the restored files and folders belong to the correct group and have expected permissions?

I understand that this might not really be an issue with Restic but more of an issue that I don’t understand permissions properly in this context. I’ve tried to find more info on this in the docs or Github repository but without luck - is this available anywhere?

Oh holly sh*t, I take back everything I wrote under Issue 2. I was able to run Restic as a non-root user and all the permissions seem to be applied as expected - which makes sense!

That same non-root user should also be able to read the drive, then - restic should have exactly the same permissions as the shell or file manager.

1 Like

So as a non-root user I can open the drive, I can add files and changes files on it (that are outside of the backup). But for some reason I don’t seem to be able to run restic mount on it as a non-root (note that I can run restore as a non-root user), this is the error that I get this time (after changing the filesystem of the external drive):

$ restic -r /run/media/user/BackupUSB/backup/ mount /mnt/restic-dir
enter password for repository
repository xxxxx opened successfully, password is correct
fusermount: exit status 1
also, the following messages were logged by a library:
mount helper error: fusermount: failed to chdir to mountpoint: Permission denied
unable to unmount (maybe already unmounted?): exit status 1: fusermount: entry for /mnt/restic-dir not found ion /etc/mtab

I can however mount the backup if I run restic with a sudo.

I’m not familiar with the intricacies here, but if you created /mnt/restic-dir using sudo, that might be the underlying cause. Some systems - such as my Debian machine - also require that you’ve jumped through a couple of hoops before you can use FUSE, which is what restic mount does. None of that applies to root.

1 Like

FUSE is telling you it failed to cd into the /mnt/restic-dir, which probably has the wrong permissions for your non-root user to access it.

1 Like

@odin @rawtaz correct. You two are legends. Mounting is solved now as well.

I really appreciate your time and help. If you’re using any donation-like platforms please send me a link (DM is fine), would love to send a donation - I’ve noticed that Restic isn’t accepting them.