Created
June 5, 2020 01:24
-
-
Save Belphemur/8a50cb3b1acbfb721976bf1a7348905e to your computer and use it in GitHub Desktop.
Borg Backup script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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