[Markdown] 

Linux hints: borg backup prune hint

borg backup prune hint

it’s very important to use “—prefix” with prune command with borgbackup, i had just done prunt without prefix and and up with loosing lot’s of data, it can be automated with something like this:

#!/bin/bash

BACKUP_PATH="/path/ro/backup/storage" #ssh path can be used here (remote machine)
PREFIX_LIST=(
    "root"
    "home"
    "data"
)

export BORG_KEY_FILE="/path/to/key.file"
export BORG_PASSPHRASE="key_file_password"

for PREFIX in "${PREFIX_LIST[@]}"
do
    borg prune -v --list --keep-monthly=1 --keep-yearly=2 --keep-daily=3 --keep-weekly=4 --prefix=$PREFIX --save-space "${BACKUP_PATH}"
done