Le script de backup peut être placé dans ~/.local/bin.
On peut sauvegarder plusieurs archives de différents répertoire dans un même repository.
Cependant, il faut veiller, lorsque l’on prune le repository, à indiquer un préfixe complet. Sinon il applique la règle à l’ensemble des archives, et virera certaines archives.
Le script ressemblerait donc à ceci :
#!/usr/bin/env bash
# conservée 2h dans l'agent SSH
ssh-add -t 7200 /home/fab/.ssh/fab_borg_ed25519
# the envvar $REPONAME is something you should just hardcode
export REPOSITORY="borg@mplborg:a"
# Fill in your password here, borg picks it up automatically
export BORG_PASSPHRASE="chutfautpasledire"
# Backup all of /home except a few excluded directories and files
borg create -v --stats --compression lz4 \
$REPOSITORY::'a-premiertruc-{now:%Y-%m-%d@%H:%M}' /home/fab/untruc
borg create -v --stats --compression lz4 \
$REPOSITORY::'a-secondtruc-{now:%Y-%m-%d@%H:%M}' /home/fab/autretruc
# Route the normal process logging to journalctl
2>&1
# If there is an error backing up, reset password envvar and exit
if [ "$?" = "1" ] ; then
export BORG_PASSPHRASE=""
exit 1
fi
borg prune -v $REPOSITORY --prefix '{hostname}-premiertruc' \
--keep-hourly=6 \
--keep-daily=7 \
--keep-weekly=4 \
--keep-monthly=6
# Unset the password
borg prune -v $REPOSITORY --prefix '{hostname}-secondtruc' \
--keep-hourly=6 \
--keep-daily=7 \
--keep-weekly=4 \
--keep-monthly=6
# Unset the password
export BORG_PASSPHRASE=""
exit 0
Tools : Backups, curl, divers, Exiftool, firejail, Fortune, Git, git-annex, Gnuplot pas des inconnus, GraphicsMagick, LaTeX, Magic Wormhole, make, Manipulation de DVDs, markdown, mkvtoolnix, Monitoring, Pandoc, Photorec & DDRescue, QR Code, Récupération de fichiers, Recutils, RFID, Rsync, Schémas, Sed, Smartmontools, SQL, tmux, Tor Boyau, Translate Shell, urxvt, wget, whois, wireshark, X2GO, xorriso