Purchase Linux CDs / DVDs / Flash Drives at OSDisc.com

Welcome to Our Community

While Linux.org has been around for a while, we recently changed management and had to purge most of the content (including users). If you signed up before April 23rd, 2017 please sign up again. Thanks!

copying files between servers using command line

Discussion in 'Command Line' started by EnWorldly, Oct 12, 2018.

  1. EnWorldly

    EnWorldly New Member

    Joined:
    Oct 12, 2018
    Messages:
    4
    Likes Received:
    4
    hi guys,
    I've got a list of files in one server location that I want to copy over to a location on a completely different server. What is the best (and most simple if possible - I'm a bit of a newbie) way to do this?

    The files are all nested inside various subfolders, but I can generate a list of them with their full directory paths.


    (Log in to hide this advertisement)


    thanks in advance for your help
     
    Peer likes this.
  2. Dimitris

    Dimitris New Member

    Joined:
    Apr 7, 2018
    Messages:
    20
    Likes Received:
    19
    Did you try

    1. scp?
    2. ssh in order to wget?
     
    CptCharis and Peer like this.
  3. EnWorldly

    EnWorldly New Member

    Joined:
    Oct 12, 2018
    Messages:
    4
    Likes Received:
    4

    Nup. Didn't really try anything yet! I do ssh into both of the servers (the source and the target), if that helps? Would you then recommend wget? Should I do that from the source location (where I am copying the files from), or the target location (where I am copying the file to)? thanks!
     
    Peer likes this.
  4. EnWorldly

    EnWorldly New Member

    Joined:
    Oct 12, 2018
    Messages:
    4
    Likes Received:
    4
    wget didn't work, because I'm sftp 'ing into the source location, and wget returned: "Unsupported scheme 'sftp'. "
     
    Peer likes this.
  5. wizardfromoz

    wizardfromoz Super Moderator
    Staff Member Gold Supporter

    Joined:
    Apr 30, 2017
    Messages:
    1,862
    Likes Received:
    1,845
    Rsync?

    (Wizard appears in a puff of smoke)

    Welcome to linux.org @EnWorldly :)

    I don't use it myself, but a lot of Sysadmins do!

    Google up

    "linux rsync" and see what you think.

    Cheers and

    Avagudweegend

    Chris Turner
    wizardfromoz
     
    atanere and Peer like this.
  6. HostechSupport

    HostechSupport New Member

    Joined:
    Sep 17, 2018
    Messages:
    4
    Likes Received:
    3
    As per above member said the both scp and rsync commands are useful to

    copy files from remote location.
     
    wizardfromoz likes this.
  7. Rob

    Rob Administrator
    Staff Member

    Joined:
    Oct 27, 2011
    Messages:
    354
    Likes Received:
    808
    Yep, rsync is your best bet here..

    Let's say you want to copy the files from server1:/path/to/files/ to server2:/other/path/ you would simply do:
    From server1:
    Code:
     rsync -avz --progress /path/to/files server2:/other/path/
    From server2:
    Code:
     rsync -avz --progress server1:/path/to/files/ /other/path/
     
    wizardfromoz likes this.
  8. EnWorldly

    EnWorldly New Member

    Joined:
    Oct 12, 2018
    Messages:
    4
    Likes Received:
    4

    Thanks Rob and WizardFromOz (yes I did avagudweegend).

    my question now is this: the files are not all in one location on the source. (They are all going to the same location at the target). So, can I put in multiple filepaths for the source files? E.g. a distinct path for each file? Like, a list of paths, as a way of defining the list of files that I want to copy across?

    cheers, Nick
     
    wizardfromoz likes this.
  9. wizardfromoz

    wizardfromoz Super Moderator
    Staff Member Gold Supporter

    Joined:
    Apr 30, 2017
    Messages:
    1,862
    Likes Received:
    1,845
    G'day Nick :)

    I will likely bail at this point, as this is beyond my paygrade :(. I use rsync on a daily basis, but indirectly, as it is the underlying engine for Tony George's Timeshift which I use daily.

    I knew of rsync's use for sysadmins in deploying packages and files remotely only through reading, but have not used it as such per se.

    @Rob , @JasKinasis and perhaps new Member @HostechSupport may be of further assistance.

    I mention Jas because as well as working in the industry, he is a "wizard" on scripting, and it sounds to me that if rsync cannot cope with the disparate paths of its own accord, then a script might be in order.

    That is just a guess.

    Good luck, I'll sit back and watch and learn :rolleyes:

    Wizard
     
    HostechSupport and CptCharis like this.
  10. Rob

    Rob Administrator
    Staff Member

    Joined:
    Oct 27, 2011
    Messages:
    354
    Likes Received:
    808
    Something like this should work..

    Code:
    rsync -avz --progress /path/to/source1/ /path/to/source2/ /path/to/source3/ [email protected]:/path/to/dest/
    You can create a couple directories to test it out first
     
    CptCharis and wizardfromoz like this.

Share This Page