5

I have two servers, let's call them sA and sB. I need to backup data (several TBs) from sA to sB but because of problems with sB SSH, I'm using my local pc as "middle man". sA is a Linux server, sB is a QNAP nas.

So first I mount sB locally with

sudo mount -t cifs //sb_host/share destdir -o username=myuser,file_mode=0777,dir_mode=0777

Then I use rsync to copy files from sA to the share:

rsync -PrlH -e '/usr/bin/ssh' myremoteuser@sa_host:/dir-to-backup/ destdir

I had to remove the -a option because times and permissions couldn't be preserved. It's not a big deal (although it would be nice to fix that), but the same happens with symlinks:

rsync: symlink "symlink_file" -> "symlink_destination_file" failed: Operation not supported (95)

Can this be fixed?

Fabio
  • 229
  • 2
  • 8
  • Can't you mount the share on sB via NFS on sA? – Sven Aug 24 '16 at 09:39
  • @Sven I have connectivity problems between sA and sB. Pings going to 100% packet loss, ssh connections dropping, rsync getting stuck.. we decided to use the "middle man" until we can decommission the old sB. Just the easiest solution. I might try an NFS share if it is robust against connection drops (of up to a minute). – Fabio Aug 24 '16 at 09:45

3 Answers3

4

I had tried "unix extensions = yes" but it didn't work - but it was just the nas overwriting the settings when restarted.

So, adding that option to the receiving server, restarting samba there and mounting share with cifs correctly handles permissions and symlinks.

Fabio
  • 229
  • 2
  • 8
  • 2
    Thank you for this post, it pointed me in the right direction. Just wanted to add that on my Synology, I had to go to `Control Panel / File Services / SMB / Advanced Settings` and had to check the box next to "Allow symbolic links within shared folders". – guttermonk Jul 31 '20 at 18:54
  • How about if the destination is hosted on Windows, is there a way to do this? – Brian Z Apr 19 '21 at 23:40
  • @Fabio can you elaborate on the specific commands/settings you used to get it to work? I tried adding `unix extensions = yes` in `/etc/samba/smb.conf` on the server and restarting samba, but that did not seem sufficient. – user2561747 May 09 '23 at 22:37
  • @guttermonk do you know how that Synology setting translates into the samba config? On your synology box do you see a change to `/etc/samba/smb.conf` when you check and uncheck that setting? – user2561747 May 09 '23 at 22:39
  • I think I may have gotten this to work by adding `follow symlinks = yes` in smb.conf (although it seems like that's already default) and mounting cifs with the extra mfsymlinks option: `sudo mount -t cifs -o username=user,vers=2.1,mfsymlinks //server/share /media/mountpoint/` – user2561747 May 10 '23 at 00:08
0

You can use rsync -rt to preserve timestamps and recurse directories--two of the main reasons for using -a, and you won't get the permissions errors.

Using NFS instead of CIFS would probably be better for your case, because NFS will pass permissions to rsync.

Note that you can use scp -3 to copy through the middleman machine without mounting anything on it. ;-)

captain
  • 1
  • 2
0

CIFS does not support symlinks

cduffin
  • 854
  • 7
  • 8