You are not logged in.

#1 2011-03-11 12:29:07

whoops
Member
Registered: 2009-03-19
Posts: 891

[resolved] filter / delete files the way rsync uses its exclude list?

edit: discovered the "--delete-excluded" - option for rsync just minutes after posting this question. rsyncing the backup to its parant directory with that option added seems to do the job.
edit: No, it doesn't. It just pretends to do the job, but doesn't really seem to delete the files.
edit: Oh god, I had --backup still activated. It did work - it just made another backup into another sub directory every time I tried. Now to clean up that mess....
edit: AND also "-b" was still in there. Will I ever learn from my mistakes?
Hi!


After updating my list of rsync excludes to be more accurate over the last weeks, I have a lot of trash still stuck in the old backups / increments. I'd like to delete those, that whould have been excluded by rsync using the new exclude file / list. Can't really find a good method, though.

To get the list of files, that...:

for expression in $(cat /home/user/scripts/backup.exclude); do find /media/BACKUP/ -regex ".*$expression.*"; done;

... seems to differ from the way rsync handles the expressions when it comes to regex special characters (*./) ... not sure how rsync does it exactly, but it works.


Is there anything that handles that better? Maybe use rsync in a way I didn't think of (sync folder with itsself in some way) or something?


thx!

Last edited by whoops (2011-03-11 12:51:57)

Offline

#2 2011-03-11 18:13:18

whatshisname
Member
Registered: 2010-04-24
Posts: 163

Re: [resolved] filter / delete files the way rsync uses its exclude list?

I use the combination of "--exclude-from" and "--delete" switch to keep all the garbage folders from my backups.

But it took a while to figure out the syntax to use in the file the "--exclude-from" switch references.  Funny how that important piece of information is never covered in any of the tutorials I could find on rsync out there.  Only this past week-end did I finally figure it out.

I had been putting absolute paths into that file for folders I didn't want to back up, for example "/home/me/.thumbnails/normal/*", but that folder kept getting backed up anyway.  Finally I paid more attention to the output on the screen going by during the backup and saw that rsync considered that folder to be named ".thumbnails/normal/".  Once I put ".thumbnails/normal/*" into the excluded files list, and all the other folders on separate lines accordingly, I finally achieved what I was looking for -- none of my "garbage" folders were being backed up and any file not found in my source folders were deleted from the target folders.

You didn't post the switches you were using for rsync but here's what mine looks like:

rsync -avr --exclude-from=/home/me/bin/exclude_from_backup.txt --delete /home/me/ /media/backup/home/me/

Hope this helps.

Offline

Board footer

Powered by FluxBB