Score:1

Filter the output of locate not to show the Duplicates in rsnapshot

ua flag

When I use locate on my server and the result is in my rsnapshot backup then I get all those duplicates.

I could use grep to filter out all rsnapshot files:

locate something_in_backup | grep -v /var/cache/rsnapshot

but then I would miss files in the backup that are coming from other servers.

How could I filter the output to show only results from the rsnapshot/daily.0/ folder?

user10489 avatar
nc flag
Best way would be to find the scripts that build the locate database and add the directories you want to filter to the blacklist in the script.
ua flag
Good idea, but I don't want that, because, I need all old backupped files in the locate database also
user10489 avatar
nc flag
If you don't want to prune the database, then `grep -v` is your friend. Locate can do some pattern matching, but it doesn't have a blacklist feature. Although it can filter by permissions, so you could make the directories unsearchable to some users.
Score:1
ua flag

You can use regular expressions in the grep command:

locate something_in_backup | grep -v 'rsnapshot/\(hourly.[1-5]\|daily\|weekly\|monthly\)'

or if you don't backup hourly:

locate something_in_backup | grep -v 'rsnapshot/\(daily.[1-7]\|weekly\|monthly\)'

note the right escaping of pipe and brackets

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.