views:

25

answers:

1

Hi, I have a fairly simply batch file to backup a Directory on Server 2008 using cwrsync to a Linux server, and to restore.

Backup script:

@ECHO OFF

SETLOCAL
SET CWRSYNCHOME=C:\Program Files (x86)\cwRsync
SET CYGWIN=nontsec
SET HOME=%HOMEDRIVE%%HOMEPATH%
SET CWOLDPATH=%PATH%
SET PATH=%CWRSYNCHOME%\BIN;%PATH%

rsync -e "ssh -i new.key" -r --verbose -tz --stats --progress --delete '/cygdrive/c/users/test/documents/' user@host:"/test/documents"

Restore script

@ECHO OFF

SETLOCAL
SET CWRSYNCHOME=C:\Program Files (x86)\cwRsync
SET CYGWIN=nontsec
SET HOME=%HOMEDRIVE%%HOMEPATH%
SET CWOLDPATH=%PATH%
SET PATH=%CWRSYNCHOME%\BIN;%PATH%

rsync -e "ssh -i new.key" -r -tz --stats --progress [email protected]:"/test/documents/" '/cygdrive/c/users/test/documents'

This has been working fine to restore the differences in files, but recently I deleted everything to test the restore functionality, and had a host of problems.

Specifically, none of the filetimes were preserved, and the creation and moficiation date of them all was the time they were downloaded as new.

Then, there were a host of problems with the NTFS permissions. Specifically, when the files were restored many now had a deny permission, which did not stop me from accessing the files, but stopped my backup script from being able to backup.

Is there a way I can preserve NTFS permissions and filetimes?

A: 

There is a fundamental difference between how windows and linux store their access-control lists (permissions) - windows has arbitrary length ACLs whereas linux/unix ACLs have fixed length - owner, group and other with read,write and execute permissions. Put simply transferring from windows to linux, what will be copied (in terms of permissions) is what CygWin thinks the Unix-style permissions for those files are which, in the general case, cannot store all the Windows-style permissions.

tobyodavies
I know the differences in ACL's, except I don't want unix style permissions stored whatsoever. Since the NTFS permissions are part of the file, surely there is a way to tell cwrsync to transfer files while ignoring the permissions?
Jacob
The NTFS permissions are _not_ part of the file, they are stored by the operating system separately to the file. This is evidenced by the fact you need to make a system call (chmod/chown in unix) to modify them and overwriting a file with another file with different permissions does not change the permissions of the overwritten file. If you are storing these files on two incompatible filesystems, you will _necessarily_ run into these problems. Since you are using a unix tool (rsync) which only understands unix-style permissions, you will need to serialize and restore these ACLs yourself.
tobyodavies
It appears cwrsync had a nontsec option, which would ignore nt permissions. This would not preserve them, but would not cause the problems with adding the deny permission either : http://stackoverflow.com/questions/2124169/cwrsync-ignores-nontsec-on-windows-7
Jacob
So, I will try the noacl option to see if this helps with permissions, but what about file times? Is there any way to preserve file times?
Jacob
i use the -a switch on rsync which preserves most stuff you need to, including timestamps, if you just need timestamps -t should do it. this is with rsync on debian... YMMV
tobyodavies