[Borgbackup] variable purge policies per filesystem tree

Antoine Beaupré anarcat at debian.org
Sat Sep 16 10:41:46 EDT 2017


Hi,

I suspect this is impossible because of the way borg is designed, but is
there a way to have different prune policies for different parts of the
filesystem?

For example, I would need to purge /var/log faster than the rest of the
filesystem. I would rather drop those after a week, but I would keep
other parts of the filesystem indefinitely.

The only way I can think of doing this is having two separate set of
archives within the repositories, with each its own purge policies.
That feels rather clunky because I need to rely on some hardcoded
special naming pattern on the archive names to purge (or not) certain
archievs.

Right now my naming scheme is, more or less:

    $(hostname)-$(date +%Y-%m-%d)$tag

where $tag is a manual tag I could append to make more than one manual
snapshot per day. Now, I am changing this to:

    $(hostname)-$tag-$(date +%Y-%m-%d)

With $tag defaulting to "auto" in the script:

    tag=${1:-auto}

It looks like a trivial change, but it allows me to use different purge
policies thanks to the -P/--prefix parameter in borg purge. I also had
to rename all archives to add the "auto" parameter:

    host=$(hostname)
    repo="."
    borg list "$repo" | sed "s/\($host-....-..-..\).*/\1/" | while read archive; do
        new=$(echo $archive | sed 's/$host-/$host-auto-/')
        echo borg rename "$repo"::"$archive" "$new"
    done

(add "| sh" to that pipeline once you're sure you like the generated script)

Then I can do the following purge policies:

    borg prune --verbose --list -d 30 -w 52 -y 10 -P $(hostname)-auto- "$repo"
    borg prune --verbose --list -d 7 -P $(hostname)-logs- "$repo"

This is in my updated cron job available here:

https://github.com/anarcat/community/tree/cron.daily

Now the only question that remains is - how do i purge the logs from
those automated archives... 

Thanks,

A.

-- 
Le travail des pauvres est la seule source de toutes les douceurs de l'existence.
                        - Bernard Mandeville


More information about the Borgbackup mailing list