Results 1 to 3 of 3

Thread: rsync specific folders

  1. #1
    Join Date
    Jan 2013
    Beans
    2

    Question rsync specific folders

    Hello!

    First time poster. Could use some help wrapping my head around an rsync issue. I know rsync is not Ubuntu specific, but I thought I would start here since Ubuntu is what I am currently using as an OS.

    I only want to backup directories within a directory with a specific name. The directory can be located anywhere within the parent, I would also like to keep directory structure intact.

    So say,

    rsync search for all directories in this "destination folder" with the name "mysearch" and backup its contents only and keep directory structure.

    Can this be done? Thanks for looking

    Cheers,
    Ash

  2. #2
    Join Date
    Dec 2009
    Beans
    166

    Re: rsync specific folders

    Quote Originally Posted by masterashley View Post
    [...]
    I only want to backup directories within a directory with a specific name. The directory can be located anywhere within the parent, I would also like to keep directory structure intact.

    So say,

    rsync search for all directories in this "destination folder" with the name "mysearch" and backup its contents only and keep directory structure.

    Can this be done? Thanks for looking

    Cheers,
    Ash
    Rsync can read paths, lists (--include-from=, etc ...) or expand shell's wildcards, but it can't do searches in the sense that you're describing here. They're usually find's domain.
    So to search for given directories anywhere in the parent's directory tree, that contain "mysearch" term and keep the directory structure intact while copying, you can do something like:

    Code:
    cd /path/to/your_directory/
    
    find . -name '*mysearch*' -type d -print0 | rsync -avr0 --files-from=- . user@remote:/destination/dir
    Note the rsync's -r (--recursive) option.
    http://linux.die.net/man/1/rsync

  3. #3
    Join Date
    Jan 2013
    Beans
    2

    Re: rsync specific folders

    Excellent!! Thanks for the input!

    Much appreciated.

Tags for this Thread

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
  •