1. IMPORTANT - 11/13/2015: In light of a possible breach we have scrubbed all passwords. You will need to request a password reset through the site. Click here for more information.

Tricky rsync question

Discussion in 'Command Line' started by Rob, Feb 27, 2013.

  1. Rob

    Rob Administrator Staff Member

    Oct 27, 2011
    Likes Received:
    Here's a good scenario that I just thought of..

    You have an existing folder with a bunch of files and directories in it. Let's call it /path/to/dest/

    You have another folder with a different bunch of files and directories in it.. lets call that /path/to/source/

    You rsync everything from /path/to/source/ into /path/to/dest/

    Then, you realize you really wanted to put things into /path/to/dest2/ instead...

    Can you tell rsync to remove everything in /path/to/dest/ that matches /path/to/source/? :)

    I almost ran into this yesterday and caught myself before I did the rsync..
  2. grash

    grash New Member

    Feb 27, 2013
    Likes Received:
    You could do something like this:

    Step1 - ls /path/to/source/ > exclude.txt

    Step2 - rsync -av --delete --exclude-from=exclude.txt /path/to/source/ /path/to/dest/

Share This Page