Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
# Path to the backup destination (lokal/SSH)
destdir="ssh://user@host.bla.blubb:22/home/user/borg"
# Name of the backup repository
repository="odroid-data-rpi"
# Directory that will be backed up
srcdir="/local/path/to/srcdir"
# Define excludes, in this case the dir "/local/path/to/srcdir/NoSyncNoBackup" will not be backed up
excludes="--exclude $srcdir/NoSyncNoBackup"
# Define if and how the backup will be encrypted
# e.g. enc="none"
enc="repokey"
# Enable/disable/define compression
compression="none"
# Define how old backups will be deleted on the destination system
pruning="--keep-within=1d --keep-daily=7 --keep-weekly=4 --keep-monthly=12"
# Use this to define where your borg binary resides on the destination system
remote_binary="--remote-path=/usr/local/bin/borg"
# Actual directory on the destination system where the backup will be stored in
repodir="$destdir"/"$repository"
# Definition of the excryption password
export BORG_PASSPHRASE="SuperSecretPassword"
###################################################################################################
# Init borg-repo if absent
borg init --encryption=$enc $repodir $remote_binary
# backup data
SECONDS=0
echo "Start of backup $(date)."
borg create --compression $compression --exclude-caches $excludes --one-file-system -v --stats --progress $repodir::'{hostname}-{now:%Y-%m-%d-%H%M%S}' $srcdir $remote_binary
echo "End of backup $(date). Duration: $SECONDS seconds"
# prune archives
borg prune -v --list $repodir --prefix '{hostname}-' $pruning $remote_binary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.