Tricky rsync question

R

Rob

Guest
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..
 


G

grash

Guest
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/
 


Members online


Top