How to backup /etc/letsencrypt to local bup repository

The following script backups your Let’s Encrypt folder. I place the script in /etc/letsencrypt/backup.sh

#!/bin/bash
export BUP_DIR=/media/usb1/letsencrypt-myserver.bup
# Init
bup -d $BUP_DIR init

# Save LetsEncrypt directory
bup -d $BUP_DIR index . --exclude csr && bup save -9 --strip-path $(pwd) -n etc-letsencrypt .

# OPTIONAL: Add par2 information
#   This is only recommended for backup on unreliable storage or for extremely critical backups
#   If you already have bitrot protection (like BTRFS with regular scrubbing), this might be overkill.
# Uncomment this line to enable:
# bup fsck -g

# OPTIONAL: Cleanup old backups
bup -d $BUP_DIR prune-older --keep-all-for 1m --keep-dailies-for 6m --keep-monthlies-for forever -9 --unsafe

Typically, you only need to adjust the BUP directory in this line:

export BUP_DIR=/media/usb1/letsencrypt-myserver.bup

In order to **automatically backup****daily,**you can use our script from How to create a systemd backup timer & service in 10 seconds. If you don’t want to read the post, just use this command:

wget -qO- https://techoverflow.net/scripts/create-backup-service.sh | sudo bash /dev/stdin

from the /etc/letsencrypt folder.