borg backup scripts used on KrautSpace infra
Find a file
2024-02-17 15:39:35 +01:00
borg-backup@.service init 2023-04-04 23:36:20 +02:00
borg-backup@.timer init 2023-04-04 23:36:20 +02:00
borg-prune@.service init 2023-04-04 23:36:20 +02:00
borg-prune@.timer init 2023-04-04 23:36:20 +02:00
exec_borg.sh exec_borg.sh: wrapper script for sandboxing borg 2023-04-06 00:59:34 +02:00
init.sh init.sh: remote path parameter validation 2023-04-06 01:00:36 +02:00
install.sh make scripts executable 2023-04-04 23:38:44 +02:00
install_as_link.sh make scripts executable 2023-04-04 23:38:44 +02:00
LICENSE Initial commit 2023-04-04 23:07:11 +02:00
README.md too much backticks 2024-02-17 15:39:35 +01:00

borg-backup-scripts

borg backup scripte used on KrautSpace infra

Requirements

sudo apt install borg

Usage

Initialization

sudo ./init.sh remote_site_1 --host=whatever.your-storagebox.de --port=23 --login=whatever --directory=/home/borg

What this does:

  • Creates a config directory at /etc/borg/remote_site_1.
  • Creates a passphrase for borg.
  • Creates a ssh keypair for the ssh connection to your remote ssh backup destination host.
  • Deploys the ssk public key to the remote ssh account using ssh-copy-id.
  • Checks if the destination path is usable.
  • Initializes the borg repository.
  • Prints out the borg repository status if initialization was successfull.
  • Attempts to continue the init process if called multiple times.

Service installation

# on productive system: copy systemd-units in /etc/systemd/system
sudo ./install.sh

# on development system: link systemd-units from current directory
sudo ./install_as_link.sh

Service activation

sudo systemctl enable borg-backup@remote_site_1.timer
sudo systemctl enable borg-prune@remote_site_1.timer

FAQ

Why so much sudo?

Good question!
The borg backup process requires priviledges to read everything you want to backup.
The systemd-units sandbox the borg process to a read-only view of the filesystem.

Can I trust this code?

Never trust anything from the internet.
Download and verify what it does. It should be somewhat readable.

How can I restore lost files?

You can manually connect to your borg repository. You'll need

  • location of your SSH key (SSH_KEY)
  • SSH user name (SSH_USER)
  • SSH host (SSH_HOST)
  • directory where the borg repo lives (BORG_REPO)
  • name of the borg repo (BORG_NAME) ` Use the following command to export a tar archive:
BORG_RSH="ssh -i SSH_KEY" borg export-tar ssh://SSH_USER@SSH_HOST/BORG_REPO::BORG_NAME TAR_NAME DIR_NAME

Borg will create a tar file with the name TAR_NAME and outputs all contents from the directory DIR_NAME into it.