rsync to cifs mount but preserve permissions

2

1

I'm backing up a linux server to a windows share. I'm currently mounting the windows share with cifs and using rsync for incremental backups. File permissions and ownership are not being preserved, as should be expected after reading this samba document:

The core CIFS protocol does not provide unix ownership information or mode for files and directories. Because of this, files and directories will generally appear to be owned by whatever values the uid= or gid= options are set, and will have permissions set to the default file_mode and dir_mode for the mount.

How can I achieve my goal of preserving unix file permissions while writing to a windows share? Is there another network file system that would allow me to do this?

Thanks.

getWeberForStackExchange

Posted 2011-06-22T18:21:33.237

Reputation: 123

Answers

1

The CIFS protocol has an extension to add support for POSIX file permissions (not sure about ACLs), which is already part of Samba. If you install Services for Unix (or whatever Microsoft calls it now), it should add this feature to Windows too. In addition, SfU comes with both server and client for NFSv3, which has been designed for Unix filesystems.

user1686

Posted 2011-06-22T18:21:33.237

Reputation: 283 655

3

Edit: As grawity points out MS has an add on package for this. Read his answer first.


It's not just the network file sharing protocol that doesn't save that kind of permission data, the windows file system itself doesn't have places for that data to go*. The only way to do this would be to add some kind of layer on top of windows to both have a file system and network protocol with those capabilities. This could be a virtual machine with a disk image, or crazy magic with cygwin, or special windows drivers, but it's all going to require some measure of work.

If your use case is really simple you like backups, you might consider using tar for instead. Or rsnap. These can make single file objects of your data with all the file permission data embedded inside, then you can compress them and send them across the network to whatever file system you like. There are even ways to deal with incremental data updates. This might be a low-tech way to solve your issue.

* unless you add in their Services for Unix toolset which sets up a comparability layer and stores the extra permission data ... somwhere.

Caleb

Posted 2011-06-22T18:21:33.237

Reputation: 4 323

If I switched to a unix share and mounted it over NFS, would I have this issue? – getWeberForStackExchange – 2011-06-22T18:35:35.720

1@weberwithoneb: No. If the remote file system has POSIX permission abilities and you share it with NFS, you would not have this issue. – Caleb – 2011-06-22T18:36:41.173

1Furthermore, you wouldn't have to mount it at all however, rsync is capable of using several network protocols (it's own, ssh, etc) to send files. The real problem is that the target file system has to support permissions and magic like that. – Caleb – 2011-06-22T18:39:49.160

@Caleb: CIFS does support Unix permissions, and Windows has "Services for Unix" to add support for the extension. – user1686 – 2011-06-23T08:07:47.670

@grawity: Then by all means add another answer! (And I'll look into correcting mine.) That's something I didn't know about. – Caleb – 2011-06-23T08:09:31.433

@weberwithonb: I was wrong, I'd forgotten about MS's Services for Unix which adds the necessary capabilities to be compatible. You can mark @grawity's answer as correct!

– Caleb – 2011-06-24T07:20:54.843

@Caleb: The latest version appears to be called Subsystem for UNIX Applications (the server side of which only comes with Windows 2k8 Server, unfortunately).

– user1686 – 2011-06-24T07:26:55.627