1

I use my NAS to back up several smaller systems that monitor the solar plant, using rsync. It works great. Now I want to back up the entire NAS drive.

There are subdirectories for each linux machine - 8 of them.

As I have learned more and tuned my exclusions I see a whole lot of leftovers that I forgot to exclude earlier.

In the past I excluded the /lost+found directories but didn't think about /.trash-1000 and now there are a lot of them.

Simply adding them to the --exclude list, even with --delete doesn't delete them because exclude makes the rsync program skip them entirely.

It does not operate the same way Robocopy /MIR does.

So let's start with .Trash and I think the answer will help me if I find others that I originally forgot to exclude.

Obviously, one solution is to delete the entire directory for each server in turn and then re-run a full rsync with the new set of exclusions.

But that is a lot of work, to say the least.

So my question is, when I make a full rsync of the NAS drive, is there a generic way to exclude all .Trash-1000 folders? If this works, I may swap the drives and resume operations with the cleaner one.

I'm looking for something like this:

--exclude="*.Trash*"

...so it would not copy them, regardless of their location in the directory structure.


I really want to know how to do this with rsync, and am looking for a solution to the problem of how adding excludes causes rsync to skip them rather than deleting them.

Alternatively, instead of doing it during the rsyncs, I would welcome an answer that would show me how to seek and destroy these directories on the original NAS drive.

rsync - How to make it delete directories or files recently added to the exclusions list

4
  • So you want to remove all *.Trash* directories that were already copied? Commented Aug 19, 2017 at 11:23
  • @Arkadiusz, YES. I would welcome a command that would seek and destroy all of them on the original. I'll alter the question to include that in case you are willing to post it as an answer. It would really help a lot with the immediate problem, even if it doesn't fix rsync. TNX
    – SDsolar
    Commented Aug 19, 2017 at 23:09
  • Well how about the --delete-before and/or --delete-after options as mentioned on the Rsync - Man. I think the Robocopy function you are referring to is the /PURGE option and I think one of those two or maybe both will do what you need—simple enough to test. Commented Aug 20, 2017 at 1:43
  • Yes, /purge is implied with /mir in robocopy. That is what I want to accomplish. But any --delete switch is not applied to anything in --exclude
    – SDsolar
    Commented Aug 20, 2017 at 4:20

2 Answers 2

0

Here are some Q&A's that talk to the alternative:

How to delete directories based on find output?

How to remove folders with a certain name

find + delete files that contain “.”

And between them I believe my best option for the immediate problem is to remove them from the original drive by executing this in the directory that contains the full backups of the other systems:

cd /mnt/full
sudo rm -rf `sudo find -type d -name '.Trash-1000'`

Search and destroy, hoo-rah!

It worked and will make future rsync work faster in the future.


This does not solve the rsync bug, though.


If anybody has an answer that will make rsync delete directories that I later add to the --exclude list, then that would be the answer I will gladly accept.

0
0

As to the first part of the answer: How to make it work like Robocopy /MIR (/PURGE),

Turns out that rsync has a

--delete-excluded

switch.

That solves the problem.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .