#!/bin/bash
# Inspired by https://borgbackup.readthedocs.org/en/stable/quickstart.html
# https://gist.github.com/ericmieth/c045edebb0709dfd88e1
# Created by mushu 2016-02-04
# Mounting the volume:
cryptsetup --key-file <keyfile> luksOpen UUID=<deviceUUID> cryptBackup
mount /dev/mapper/cryptBackup /mnt
# Performing the backup:
name=$(date -I)
sources='/etc /home /root'
target='/mnt/backups'
# Create a new backup:
borg create --exclude-caches $target::$name $sources
# Remove old backups:
borg prune -v $target --keep-daily=7 --keep-weekly=4 --keep-monthly=6
# Display current backups:
borg list $target
# Umounting the volume:
sync && umount /mnt
cryptsetup luksClose /dev/mapper/cryptBackup
#!/bin/bash
# Inspired by https://borgbackup.readthedocs.org/en/stable/quickstart.html
# https://gist.github.com/ericmieth/c045edebb0709dfd88e1
# Created by mushu 2016-02-22
# Mounting the volume:
cryptsetup --key-file <keyFile> luksOpen UUID=<deviceUUID> cryptBackup
mount /dev/mapper/cryptBackup /mnt
# Verifying current backups:
borg check /mnt/backups
# Umounting the volume:
sync && umount /mnt
cryptsetup luksClose /dev/mapper/cryptBackup
# Scrub local btrfs:
btrfs scrub start / -B
# Going to sleep:
systemctl suspend