I'm starting to use robocopy for my daily backups from my computer to my NAS (Openmediavault, with a Samba sharing). The target is create a mirror of my Z:\ disk into the NAS. To make it possible I use this line into a batch file:
robocopy "Z:\ " ^
"\\OMV\Backup\ " ^
/XD "?RECYCLE.BIN" "System Volume Information" "\\OMV\Backup\.recycle" ^
/XF "Thumbs.db" ^
/MIR ^
/IT ^
/COPY:DAT /DCOPY:DAT ^
/R:0 ^
/NDL ^
/FFT
It seems to works well, but everytime I start the script, robocopy copy every local file starting with "." into the NAS, even if it has not been modified. There are hundreds of these files on my disk, so this becomes an annoying behavior for me.
(extract from the log:
Variato 3515 Z:\Progetti\(2022-05-16) - Music Selector\sourcecode\home\thfx\.bashrc
Variato 4240 Z:\Progetti\(2022-05-16) - Music Selector\sourcecode\home\thfx\.bash_history
Variato 220 Z:\Progetti\(2022-05-16) - Music Selector\sourcecode\home\thfx\.bash_logout
Variato 675 Z:\Progetti\(2022-05-16) - Music Selector\sourcecode\home\thfx\.profile
Variato 66 Z:\Progetti\(2022-05-16) - Music Selector\sourcecode\home\thfx\.selected_editor
Variato 0 Z:\Progetti\(2022-05-16) - Music Selector\sourcecode\home\thfx\.Xauthority
Is there a trick to avoid this and copy the files only if they have actually changed?
(I fully understand that the problem is on the server side, where the Samba share doesn't handle file attributes in the same way windows does, but it seems strange to me that on internet there are not info about this strange behaviour.)
As I mentioned in the question, the issue is on the server side.
There is an option on Samba, that "hide dot files", and it is enabled by default.
I turned off this option on the Samba configuration file, restarted Samba service, and now the script works without issues.
If you are using OpenMediaVault like me, you can deselect the option on the web interface, editing the shared folder. (screenshot)