Page content


how do you backup your data … ? a really cool solution is borgbackup.

BorgBackup (short: Borg) gives you:

  • Space efficient storage of backups
  • Secure, authenticated encryption.
  • Compression: LZ4, zlib, LZMA, zstd (since borg 1.1.4).
  • Easy installation on multiple platforms: Linux, macOS, BSD, …
  • Free software (BSD license).
  • Backed by a large and active open source community.

Always a good Idea is to keep a Backup external. has a really competitve Offer (without Support). 100 GB for $18/year.

Install Borgbackup

pkg_add borgbackup

Generate KeyPair

mkdir /backup
ssh-keygen -o -a 100 -t ed25519 -C '"My Rsync Key"' -f /backup/id_ed25519_rsync-net

Public Key

you need to create an account at (or wherever you want) and put your public key (/backup/ to the .ssh/authrorized_key file

Backup Script

cat <<'EOF' > /backup/

# Vars

_date=$(date +"%Y%m%d-%H%M")

# Exports
export BORG_RSH='ssh -i /backup/id_ed25519_rsync-net'
export BORG_PASSPHRASE="${_passphrase}"
export BORG_REMOTE_PATH=borg1
export repo="${_rsync_user}@${_rsync_host}:${_app}"

## Hints ##

# Create Repo
#borg init -e repokey-blake2 ${repo}

# List Repo
#borg list ${repo} |grep ${_host}

# Show Last Backup
#borg list ${repo} |grep ${_host} |head -1 |awk '{print $1}'

# Restore File from last Backup
#borg extract ${repo}::`borg list ${repo} |grep ${_host} |head -1 |awk '{print $1}'` etc/hosts

# Do Backup
/usr/local/bin/borg create --compression lz4 -e keyfile ${_param} ${repo}::${_host}-${_date} \
        / \
        --exclude "*.pyc" \
        --exclude "*__pycache__*" \
        --exclude "/mnt" \
        --exclude "/tmp"

# Do Cleanup
/usr/local/bin/borg prune -v --list ${repo} --prefix ${_host} \
        --keep-hourly=2 \
        --keep-daily=8 \
        --keep-weekly=5 \
        --keep-monthly=13 \

# Done
exit 0

chmod 700 /backup/

you can now start your first backup by hand: ./backup/borgbackup and then add cronjob and run it daily