rsync from linux to cygwin on windows

Need to rsync from linux box to local windows. Have cygwin installed but after file transfer the CHOWN is ADMIN:ADMIN.
I need to preserve the original ownership from the linux server, i.e. for mysql files would be mysql:mysql.
Is there a way to accomplish this with any rsync option? Options -og do not preserve the ownership.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gerwin Jansen, EE MVETopic Advisor Commented:
If you want to create a backup and rsync that to Windows, I suggest you create a tar file first on your Linux machine and then rsync that to Windows. Windows does not know of your (local) Linux accounts so I believe you will not get that to work the way you think it would.
nerkoniAuthor Commented:
That is what I thought too. So I could just tar the whole / directory, right?
Once is rsync-ed over to my PC, I would just delete it. Should not be too big, some 5-6 GBs.
In that case I would exclude the /backup dir since I am already making a backup.
Any suggestions which other directories to exclude from the tar file?
Gerwin Jansen, EE MVETopic Advisor Commented:
I would not tar the whole / directory - this would mean your complete file system.

I would just tar your 'mysql' directory and then rsync that tar file to the destination (or just SFTP it).

Check the backup/tar by copying it back so you know you get the correct ownership etc.
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Making a tarfile may give you an option for getting the permissions you want carried over, but it completely defeats one of the main advantages of rsync which is transmitting (hopefully) only the parts of files that have changed.

You can specify a login name as part of the destination for rsync, but that may not work if your mysql account isn't allowed to login or authenticate.
nerkoniAuthor Commented:
Maybe I was not clear in my initial question. I would like to copy the entire server either to cygwin or local virtual machine. If I do it to my windows box which uses cygwin, I will loose the original file/dir permissions from my server since local machine does not know about these accounts.
How could I create an image (i.e. ISO) to use it for booting my virtual machine on my windows box?
Gerwin Jansen, EE MVETopic Advisor Commented:
>How could I create an image (i.e. ISO) to use it for booting my virtual machine on my windows box?
That is a complete different question, not something you can do with rsync. I suggest you delete this question and ask a new one.
You said rsync in your question, but now you describe wanting to run a virtual image of the Linux system. For that, you'd want to do a P2V or V2V conversion so that the contents of the Linux system end up intact in whatever form or package (probably a VHD?)  your Windows system likes to find its VM guests in.

If nothing else presents itself, you could still use rsync, but between two Linux live CD-based supervisors, one booted in the context the the source system and a second booted in the context of the target VM guest. Contents of the filesystems from one transfer intact to the contents of the filesystems of the other. You may need to make a few additional adjustments (something that P2V software takes care of for you) to accommodate the different (virtual) hardware environment that will be experienced by the new target machine.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nerkoniAuthor Commented:
My bad. I gave an example of MySQL directory and forgot to mention that I want the whole server copied over to my local machine.
I already have a copy of MySQL on my machine and my next step is to copy everything else as I wanted to keep it in sync with the server.
On top of that I need to be able to use same environment on local machine for local development.
Sorry for the confusion.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.