Skip to content

Instantly share code, notes, and snippets.

@Belphemur
Created June 5, 2020 01:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Belphemur/8a50cb3b1acbfb721976bf1a7348905e to your computer and use it in GitHub Desktop.
Save Belphemur/8a50cb3b1acbfb721976bf1a7348905e to your computer and use it in GitHub Desktop.
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