Xtreamer Support System



How to sync Windows folders with eTRAYz (SyncFolder for Win)





Why do it - short description
I want to backup some of my Windows files to eTRAYz at daily basis. In LAN - its not a problem. Just copy and forget. Via Internet - there is FTP. But what if my directory is rather big (3Gb, 16K files) and I really dont remember which files were changed or are the new ones?
I do the synchronization with rsync. Magic :) No expensive 3rd party software needed.
Its same solution that was used by eTRAYz developers to introduce SyncFolder feature. So far SyncFolder works only between eTRAYz devices. Now you will be able to make folder synchronization with eTRAYz from yours Windows machine (it works with Linux based and Macs as well...)

So lets do it through the Internet. But remember to make it secure!
When there is a need, there is a solution for it. Here is my small howto:

Quick info
eTRAYz guys made it by default impossible to run shell for any other user then sysadmin/root.
We have to change it first so chosen users will be able to connect via ssh and to use rsync.
There was also a problem with ssh keygen - we'll obey it in easy way.
At the end you will be able to synchronize any chosen folder with eTRAYz via Internet.

Disclaimer
I will not take any responsibility if you broke anything within software of yours etrayz.
All steps descibed below were tested and eveyrhing works fine with me. Should with yours etrayz too but
I did assumed that people who will use this how-to have at least minimum knowledge of Linux systems.
I do not answer how to edit and copy files etc... You will have to google it or ask here for help.

Step-by-step
Chose yours user that you want to use for synchronization.
Then login via SSH to etrayz at root account. Password is same as sysadmin. Please be careful while doing
things as root!
Edit /etc/passwd file with:
Code:
vi /etc/passwd

or any other editing software and find line with chosen user.
Change last: /bin/false to /bin/sh
This adds shell to chosen user.
Save file.
Then change permissions to urandom with:
Code:
chmod go+r /dev/urandom

And then logout from root account. We are done here.

System is ready for reception of rsync for chosen user.

Now the clients that we want to sync. If they are linux-based then in most of the cases you dont have to add anything. SSH and rsync are so common that are easy to find in most of distry.

If you use Windows machine (like me) and would like to rsync files from it to QNAP then you have to install Windows cygwin port of rsync. I advise http://itefix.no/cwrsync/
From command line run command:
Code:
rsync.exe -v -rlt -z --delete --rsh="ssh -l username -p XX" --progress --stats --no-whole-file "/cygdrive/drivename/path/" "username@yoursetrayzname.myetrayz.net:/home/username/path/"


Where:
username - is obviously an user account that we want to SSH in and use for replication
XX - mentioned above port no used for OpenSSH
drivename/path/ - path of source files for replication
yoursetrayzname - guess what :)
username/path - remote path for replication - where we want to put our files - use chosen username and path to chosen directory for target

Here is an example of my command:

Code:
rsync.exe  -v -rlt -z --delete --rsh="ssh -l username -p XX" --progress --stats --no-whole-file "/cygdrive/D/Documents/" "username@yoursetrayzname.myetrayz.net:/home/username/Documents/"


It should work. First run will take some time depends on the size and file numbers we want to replicate. All next usage should be quick - only new or changed files are updated. Please notice that I use the --delete parameter. Which means that if I delete some file at the source, it will disappear at the destination drive. With it I make an exact mirror of my documents. Be careful with it! If you add wrong target path you can delete all files inside!

Disadvantage so far - everytime you run rsync.exe command (advise to make .bat file with all parameters) you
have to enter user password via keyboard. If you want to make sync automatically you have to run few more steps:

Login as chosen user via ssh and run:
Code:
ssh-keygen.exe -t rsa

Click 2 times ENTER as you want to make those files in default directory and with EMPTY passphrase.
Keygen should be made with empty password. This will give us possibility to make all things automatically.
Write down where keygens were saved. At Windows Vista its in
Code:
C:\Users\username\.ssh\


copy id_rsa.pub file into a .ssh directory in home directory of user used for rsync

and thats it. Next time you run rsync command it will not ask for keys.

I assumed that people reading this do have some knowledge of linux. If not - let me know and I will expand some of the issues (like - how to copy .pub file into .ssh directory).

Please remember to secure yours id_rsa private key!




Related Articles

No related articles were found.

Attachments

No attachments were found.

Visitor Comments

Article Details

Last Updated
18th of February, 2010

Would you like to...

Print this page  Print this page

Email this page  Email this page

Post a comment  Post a comment

 Subscribe me

Subscribe me  Add to favorites

Remove Highlighting Remove Highlighting

Edit this Article

Quick Edit

Export to PDF


User Opinions

No users have voted.

How would you rate this answer?




Thank you for rating this answer.

Continue