I’m trying to sync a snapshot folder I have in my linux machine to a windows machine, however, when I try to do so, I get an error that I don’t have the privilege since the snapshot folder is owned by root.
here’s what I tried:
Manually creating the ‘.stfolder’, owned by the user. No success
changed the parent directory ‘snapshot’ ownership to user, so /foo/bar/snapshot/.stfolder/ is read/writable by the user. No success
tried to play with systemd permission and run syncthing from there. No success
Creating the file or folder .stfolder by whatever means should be sufficient. I don’t know what a timeshift snapshot folder is, but if it’s some special mounted thing then maybe it’s read only and you can’t create random stuff in it. In that case you can change (in the advanced config) the marker name that Syncthing looks for to something else that should always be present.
Nope, just a normal directory, except it’s owned by root, you can create, edit, delete, etc. given you have the privileges, or change owner ‘chown’ it.
something else that should always be present
There’s nothing persistent inside the snapshot folder, it goes like this
/foo/bar/snapshots/
/snapshot1-(date)-XYZ/
/snapshot2-(date)-XYZ/
…
And these get deleted after sometime to make space for the new ones.
Additionally, even if I changed the ‘snapshot’ directory owner, I get another type of error, that can’t check the hash or integrity of each folder/files inside it because, again, they are root owned.
Also, I can’t make the folders inside as owned by a normal user, because timeshift (the snapshot program) won’t work or will overwrite them again with root owned folders.
so the easiest (or probably the only) solution is how would I sync root owned folders?
There is no special technique required, all Syncthing needs is read access and that a specified token file (which is by default called .stfolder but can be anything with configuration) exists.
I also noticed in my other machine, inside .stfolder there’s a txt file with the ‘Folder ID’, I copied it manually there too but I still have the same errors.
To update: I changed the ownership of the parent directory, in this case
/foo/bar/timeshift/snapshots
and I created a new folder in syncthing, it added the .stfolder AND the file inside automatically, and I can see some files are starting to go through and being sent!
The only issue is I still have the errors above, and I’m not sure if that is corrupting the snapshot or not, so if anyone is reading this and is in the same situation, test it first!
Last question, I did enable the systemd for synthing, does that mean it will start automatically or do I need to manually start it every time? as when I started it by systemd it said failed to start and threw an error
Those errors aren’t unusual given that directories such as /etc/ssl/private are usually owned by and only readable by root.
On a related note, if your Timeshift snapshots being copied by Syncthing to a Windows machine are for restoring personal files, it’ll be mostly fine (some configuration files require specific permissions to function properly). But restoring system files are going to cause all kind of issues because Linux and Windows don’t share the same security model.
What was the error?
(Replace the “start” command to systemctl with status to view any errors.)
Yes, if Syncthing is enabled as a “system” service it’ll start automatically at system boot time. But if it’s a “user” service it requires one extra step. What was the exact systemctl command you used?