Borg on USB


Requirements


Install borg and python-llfuse.

Mount the USB stick and make a directory for the backup. Create a password in pass and select the directories to back up with borg.

1usbpath=/mnt/usb
2backup_directory="${usbpath}/borg"
3export BORG_PASSCOMMAND="pass ${borgpass}"
4targets='~/dl ~/img ~/pro' # Select directories to back up

Initiate the borg repo.

1
2borg init --encryption=repokey ${backup_directory}
3
4borg create --filter AME --verbose --stats  \
5${backup_directory}::'{hostname}-{now}' ${targets}
6
7borg prune ${backup_directory} --list --glob-archives '{hostname}-*' \
8--keep-daily 7 --keep-weekly 4 --keep-monthly 6

Your key is in ${backup_directory}/config.

1more ${backup_directory}/config

Check the backups:

 1borg list ${backup_directory}
 2borg list ${backup_directory} | head -1 | awk '{print $1}'
 3backup="!!"
 4
 5mnt=borg_backup_mount
 6mkdir "${mnt}"
 7borg mount "${backup}" "${mnt}"
 8ls "${mnt}"
 9borg umount "${mnt}"
10rmdir "${mnt}"