Find the answer to your Linux question:
Results 1 to 6 of 6
hi guys, im new to Linux etc etc im trying to run rsync from a windows server 2008 r2 server to my centos box 20km away using a ssh tunnel ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Dec 2012
    Posts
    56

    Rsync over ssh tunnel using cygwin


    hi guys,

    im new to Linux etc etc

    im trying to run rsync from a windows server 2008 r2 server to my centos box 20km away using a ssh tunnel

    i have the ssh tunnel sorted with keys etc...when i type user@ipaddress i dont get prompted for a password

    i was just trying to copy one of the smaller directories from my cygwin shell for testing purposes but have had no luck...

    here is what command im using and whats happening

    Code:
    rsync -auv cygdrive/d/adtdata  User@121.5.23.1:home/user/companydata/adt
    when i enter the command i get a return...

    Code:
    rsync; change_dir /cygdrive/d//cygdrive/d failed: no such file or directory (2)
    rsync; change_dir #3 /home/user/companydata failed: no such file or directory (2)
    But the directories on the receiving server have been created and i can navigate them no problem...

    what have i got wrong???

    any ideas, please
    j0n1n
    Last edited by atreyu; 11-20-2013 at 05:02 AM. Reason: added CODE tags to aid in readability

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Is User really user? I ask b/c in your remote path, you say home/user/.... anyway, when you ssh in, by default you are in your home directory already, so you can leave off that bit, e.g.:

    Code:
    rsync -auv cygdrive/d/adtdata  User@x.x.x.x:companydata/adt
    or you can supply the full absolute path (you left off the leading "/" in yours), e.g:
    Code:
    rsync -auv cygdrive/d/adtdata  User@x.x.x.x:/home/user/companydata/adt
    you could supply a relative path too, of course - but I doubt the relative path you supplied (home/user/companydata/adt) exists in User's home directory. For example, if User's home directory is /home/user, then your command attempts to copy to this dir:

    Code:
    /home/user/home/user/companydata/adt

  3. #3
    Just Joined!
    Join Date
    Dec 2012
    Posts
    56
    Thanks a mill Atreyu!!! after reading your reply it made things a lot clearer...
    seems all i was missing was / before cygwin...just copied over 1gb (very fast!!!) to my remote server...im ecstatic!!!!!!!!!!!

    one last question
    is there a quick way to add a list of folders to a rsync command for a bash script?
    or do i just repeat the same command for each directory i wish to backup and then get cron to run the script...

    thanks again
    j0n1n

  4. #4
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by j0n1n View Post
    is there a quick way to add a list of folders to a rsync command for a bash script?
    or do i just repeat the same command for each directory i wish to backup and then get cron to run the script...
    well, you could put all your dirs in a file, and then tell rsync to use that file as a filter for what to get, e.g.:

    Code:
    $ cat dirs-to-rsync.txt
    testdir1
    testdir2
    $ ls -F sourcedir
    test1.txt test2.txt test3.txt testdir1/ testdir2/ testdir3/
    $ rsync -avn --files-from=dirs-to-rsync.txt sourcedir/ targetdir/
    building file list ... done
    testdir1/
    testdir2/
    
    sent 65 bytes  received 18 bytes  166.00 bytes/sec
    total size is 0  speedup is 0.00 (DRY RUN)
    $
    Note: I'm using the -n switch to rsync to run a dry-run first; it doesn't actually copy anything.

  5. #5
    Just Joined!
    Join Date
    Dec 2012
    Posts
    56
    so whats the point of a dry run??? im curios...also how come when i see people writing rsync commands they never use -r dont you have to use -r to copy files recursively so that folders within the folders get copied...or does rsync do this by default...ay!!! your help is invaluable...thanks!!!

  6. #6
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by j0n1n View Post
    so whats the point of a dry run???
    to see what is going to happen (i.e., what is going to be copied) before the copy is actually done. all the checking of files is done to see what needs to be copied, and what doesn't, but it doesn't actually perform the copy. This would be useful if you are say, using a file to tell rsync what you want to copy, but are not sure if it is right, and you don't want to accidentally rsync 10GB of data, when you only wanted to rsync 10MB!

    im curios...also how come when i see people writing rsync commands they never use -r dont you have to use -r to copy files recursively so that folders within the folders get copied...or does rsync do this by default...
    well, i guess that is a case-by-case basis. perhaps people don't want to copy whole directories, and just want to sync the files in them. but keep this in mind; you might see the "-a" option with rsync a lot. This stands for "archive", and includes "-r" along with a bunch of other options. From the man page:

    -a, --archive archive mode; equals -rlptgoD (no -H,-A,-X)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •