How can I keep copying after a "NT_STATUS_SHARING_VIOLATION" error with smbclient?

0

I have a directory of files that need to be copied every night as a backup.

I am using 'smbclient' to backup the files to a Linux machine but I am seeing an issue where if a file is locked the entire copy process will abort with a NT_STATUS_SHARING_VIOLATION error.

Is there any way to get smbclient to keep copying the rest of the files in the directory and gracefully skip over the locked files?

Atari911

Posted 2015-03-05T01:00:12.747

Reputation: 718

Answers

1

Don't use smbclient. Mount the shared drive somewhere using mount.cifs and use rsync to make the backup. Example:

# mount.cifs //server/share /mnt/cifs
# rsync -a /mnt/cifs/directory ~/backups

This would mount the share to /mnt/cifs and then recursively copy directory to ~/backups/directory.

Read up on the usage of rsync since it is a powerful program and has a few gotchas.

hololeap

Posted 2015-03-05T01:00:12.747

Reputation: 951

I could be wrong but if the windows server has a lock on the file then wont the rsync behavior be the same as the smbclient? – Atari911 – 2015-03-06T03:05:45.113

From a semi-official source: "Rsync does continue after it encounters a permission denied error." This should pertain to your case as well. As far as I have seen, rsync never quits on a read error for individual files.

– hololeap – 2015-03-08T09:10:44.037

1What do you know, this worked like a charm. Sometimes its just about using the right tool for the job I guess. - The only thing i did different was use cygwin to get an rsync/ssh connection to the windows machine. – Atari911 – 2015-03-09T23:28:31.307