Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Borg Backup script
#!/bin/sh
REPOSITORY=_SERVER_:_PATH_
BORG_CMD="borg"
BACKUP_DIR="/"
BACKUP_OPTIONS="--compress zstd,8 -v"
BACKUP_PREFIX="ns2"
export BORG_PASSPHRASE="_PASS_PHRASE"
EXCLUDE="/proc /boot /dev /mnt /sys /tmp"
for ex in $EXCLUDE
do
BACKUP_OPTIONS="$BACKUP_OPTIONS --exclude $ex"
done
#!/bin/sh
. /root/.borg.conf
# Backup all of /home and /var/www except a few
# excluded directories
${BORG_CMD} create --stats "$@" \
${REPOSITORY}::${BACKUP_PREFIX}-`date +%Y-%m-%d` \
${BACKUP_DIR} \
${BACKUP_OPTIONS}
# Use the `prune` subcommand to maintain 7 daily, 4 weekly
# and 6 monthly archives.
${BORG_CMD} prune -v $REPOSITORY --keep-daily=7 --keep-weekly=4 --keep-monthly=6 --list --stats
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment