Howto export an encrypted borgbackup archive

Borgbackup is a deduplicating backup program with encryption and compresssion. It uses a sophisticated storage format to fullfill those features.

Each backup run is stored in a so called archive. Sometimes you may want to keep a specific archive in long term storage – indepenend of any specific software specific format – let say as regular tar file.

export_encrypted_borgbackup.sh is a simple wrapper around borgbackup’s export-tar command encrypts and sign with gnupgs main identify keys.

Usage example (assuming that the env variable BORG_REPO is set):

$ export_encrypted_borgbackup.sh ::hostname-2020-06-05_22:19:17 /tmp/out.tar.gpg
[...]
$ file /tmp/out.tar.gpg
/tmp/out.tar.gpg: PGP RSA encrypted session key - keyid: xxxx RSA (Encrypt or Sign) 4096b .