Results 1 to 6 of 6

Thread: Recursive copy with scp

  1. #1
    Join Date
    Nov 2005
    Beans
    44

    Recursive copy with scp

    Must be doing something really stupid here. All I want to do is copy a selection of specific files in various folders from my webserver to my home machine.

    I'm using : scp -r *something.jpg me@home.server:/backup/

    This mostly works. It's recursively copying from directories on the webserver to my home machine... except! I'm losing the directory names, everything arrives in the backup folder on my home machine. How do I maintain the directory structure?

    Not sure if TARing and then copying that is doable as I have almost 0 free space on my webserver

  2. #2
    Join Date
    Oct 2008
    Location
    colachel
    Beans
    517
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: Recursive copy with scp

    Give the parent folder name for copying, so it copy the all the directory inside the parent directory.

    scp -r root@remoteserveripaddress.com:/home/test/ /backup

  3. #3
    Join Date
    Aug 2006
    Beans
    Hidden!
    Distro
    Kubuntu 9.04 Jaunty Jackalope

    Re: Recursive copy with scp

    You can give rsync a try. It supports replicating the entire directory structure and also elaborate filtering mechanisms via the '--filter' option.
    It is more suitable for mirroring though (uses lot less bandwidth as it only transfers changes and not the entire file), if you just want to do a one time copy scp -r should be fine.
    Last edited by nikhilk; June 11th, 2009 at 09:54 AM.
    I laugh in the face of danger:
    then hide until it goes away.

  4. #4
    Join Date
    Nov 2005
    Beans
    44

    Re: Recursive copy with scp

    Quote Originally Posted by sahabcse View Post
    Give the parent folder name for copying, so it copy the all the directory inside the parent directory.

    scp -r root@remoteserveripaddress.com:/home/test/ /backup
    This doesn't seem to work for me. I want to copy specific files, not just entire directories.

    Maybe find with xargs is the answer?

  5. #5
    Join Date
    Apr 2013
    Beans
    4

    Re: Recursive copy with scp

    A few years late, but thanks for the info! Works great!

    scp -r user@host:/folder/ ~/

  6. #6
    Join Date
    Jul 2007
    Location
    Magic City of the Plains
    Beans
    Hidden!
    Distro
    Xubuntu Development Release

    Re: Recursive copy with scp

    Closed, please don't bump old threads.

Bookmarks

Posting Permissions

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