0

I know this is is an extensively documented subject and despite the pages and pages of information ive found on it online I still cant find a definitive answer to this question so please bear with me.

I have a linux server and im trying to back up said server onto a windows machine through ssh. Im using rsync and running it from the windows box with cygwin. The problem is the permissions and the ownership from the linux server the files are being pulled from is being changed to the window's user pulling the files with cygwin. For example linux test file is owned by user dog. User cat on the windows machine initiates the command with cygwin to rsync the files over. When I look at the test file that got copied over they are not owned by user dog anymore. They are now changed to user cat and the group just says "none". I hope this is all clear enough. The permissions are not copying over correctly either. It's staying 644 on the windows machine no matter what the original permissions were.

Obviously if I need to restore the backup in the future im going to want to be able to copy everything back over and have the same ownership and permissions that were originally there or a lot of things are going to be broken. Ive seen people suggest making scripts that change chmod and chown as the files are being copied but my server has several different users and a lot of different set permissions just as im sure most of us have so im not trying to micromanage the backup process "that" much. The command im typing is

rsync -av -e "ssh -p 44" root@blahblah:/home/dog/backup /backup/

I'll explain this a little. Yes, im running it via root so that I can copy even root's files over. It is through a private key that is command forced or whatever its called to only run specific commands as to mitigate the potential security holes caused by this. (im aware you can run rsync via sudo but i havnt had much luck with it and dont really understand how its any better if you are able to specify the only thing the root user is allowed to do). The "noacl" command that cygwin has in the fstab folder has already been put in per (https://cygwin.com/ml/cygwin/2011-02/msg00116.html). From what I understand that should keep windows from trying to make sense of linux's way of doing user:group/permissions and changing this amok. Unfortunately this has had no affect and I am only 80% sure ive done it correctly. Also the windows machine initiating the backup is the administrator. The only thing I can guess at is ive read a lot about both sides having to be root for everything to copy over correctly. From what ive seen cygwin cant be run as root or even sudo and im guessing being the administrator and running cygwin as administrator would be the equivalent. Maybe not.

I really dont understand what im doing wrong or why it's not working. If rsync just cant copy linux's files without changing things then why is rsync a viable option when it comes to backing your server up onto your desktop? Am I missing something or am I just asking too much from this program? Any help or enlightenment that you guys can give me would be amazing. This is driving me crazy. (Sorry this is so long. Im trying to be as thorough as possible with my question to make it easier for everyone involved)

0

Windows filesystem and Linux filesystems are a lot different. I don't think NTFS will handle Linux permissions. Rsync will not be able to map them.

2 solutions come to my mind:

  • Make a tar.gz or tar.bz2 of Linux stuff and using netcat you can save directly to Windows Filesystem.
  • Make a big raw file in Windows, share with CIFS, mount in Linux as loopback, format it as ext3/ext4/ or anything else and rsync to it. I did this to backup my workstation to a samba share. It is tricky. You need to send some "sync" commands from the Linux box. I can help you with more detail from this setup if you want.
  • So you're saying I can use tar to put everything from my server into one big o'l container. And then send that container over to my windows machine with netcat? I assume I wouldnt be able to have incremental backups then right? Id just mass backup regularly and send it over? Also, I dont know a lot about netcat so im probably coming across as ignorant. But couldnt I just ssh the tar? Or is netcat able to be encrypted? Or just use rsync to send the tar since its already setup? – Lunakyra Dec 17 '15 at 21:23
  • This is 3 years old .. :) .. I am still using something similar to what I proposed. You need to mount your remote windows share inside linux box. You create a big container file inside that mounted share path. You use losetup to have that big file as a device in a /dev/loop3, for example. Then you create a filesystem inside it, for example, mkfs.ext2 /dev/loop3 ... Then you mount it again (/dev/loop3) in your linux box. Now you can sync your linux content with this filesystem in /dev/loop3. After rsync completes, you umount /dev/loop3, do a fsck to /dev/loop3, destroy /dev/loop3, – Jose Tavares Jul 30 '18 at 22:18
  • ... and umount your windows desktop share. Got it? – Jose Tavares Jul 30 '18 at 22:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.