My situation: I have a NAS which serves shares via CIFS/Samba. Internally, it uses an ext3 filesystem, but this is not relevant (I think). I have some Linux computers (using ext4 filesystems) which I want to back up on those shares.
My problem: Using the share for backups poses 2 main problems. On the one hand, I cannot copy all files to the NAS, because some files have very long filenames which CIFS can't handle. On the other hand, file and directory permissions are not copied correctly. For example, every file on the share has all the "execute" bits set, regardless of the original file's permissions.
My question: What is the easiest way to circumvent these "shortcomings" so I can back up and restore files without manually handling filenames and permissions?
Some additional info about my experiments so far:
My first idea was to just create ext4 filesystems within (sparse) files on the share, then mount those and use them for the actual backups. The drawback here is that removing files from the filesystems doesn't decrease the size of the ext4 "files" on the share and the filesystems have to be limited in size from the beginning. It's cumbersome to resize them after creation.
I tried to use ecryptfs because I hoped it would encrypt the filenames and permissions in a way that would get them around the CIFS limitations. This didn't work, since filenames are encrypted, but used as filenames again (so long filenames only get longer, not shorter). Also, permissions are not "hidden" by ecryptfs. The encrypted files just keep the permissions of the originals, so any decrypted file would again have all "execute" bits set.
A friendly person on IRC recommended using a dynamic number of large files and use them as volumes for LVM. I have not tested this out yet, but in theory it should work. I would have a logical volume with an ext4 which would be spread among multiple files on the share. If I needed more space, I'd create more files and add them to the volume, if I used less space I could remove some. The only drawback here is that I'd still have to perform the resizes (and periodic checks how much space is actually needed). In retrospect, this provides little to no advantage over using single files, since I could truncate/grow them and then resize the ext4 filesystem as well.
What I imagine is e.g. a FUSE which saves filenames and permissions in, say, a database and doesn't rely on the underlying filesystem to support everything. Unfortunately, I haven't fount anything like this yet.