From 91ff2e96bb038be3b0cbf31cab28fbbb1452187e Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Thu, 14 Apr 2016 13:59:38 +0200 Subject: backup.sh: Misc changes; drop duplicity Signed-off-by: Florian Pritz --- backup.sh | 65 +++++++++++++-------------------------------------------------- 1 file changed, 13 insertions(+), 52 deletions(-) (limited to 'backup.sh') diff --git a/backup.sh b/backup.sh index e191f3a..951a4e9 100755 --- a/backup.sh +++ b/backup.sh @@ -1,14 +1,15 @@ #!/bin/bash # -# This is a simple backup script using duplicity. It's supposed to serve as a +# This is a simple backup script using borg. It's supposed to serve as a # starting point and to be adjusted to your system. # # Important steps: # - define a host "backup" in root's .ssh/config # - read the script and adjust to your needs -# - export BORG_REPO in your environment or create a wrapper in $PATH that -# does it for calls to borg (my preference). For details on the variable -# see man borg +# - As root run `borg init -v --encryption=keyfile backup:borg-$HOSTNAME` +# (note that zsh uses $HOST instead of $HOSTNAME) +# - If you want, increase the max_segment_size in +# ssh://backup/borg-$HOSTNAME/config from the default 5MiB set -e @@ -43,19 +44,8 @@ main() { /mnt/data ) - # first line that matches wins - IFS='' read -r -d '' excludeList < "$TMPDIR/exclude-list" echo "$excludeList_borg" > "$TMPDIR/exclude-list-borg" # save some data that's useful for restores @@ -78,43 +67,15 @@ EOF df -a > "$backupDataDir/df" findmnt -l > "$backupDataDir/findmnt" - backup_borg / - - #local backupdir="$HOSTNAME-backup/full-backup" - #backup_duplicity / "sftp://backup/$backupdir/" --exclude-filelist "$TMPDIR/exclude-list" - #ssh backup "touch $backupdir/last-backup-timestamp" -} - -backup_duplicity() { - local src=$1 - local dest=$2 - shift 2 - local -a options=() - - if [[ $(date +%d ) == '1' ]]; then - # try to only run full backups on day 1 each month - options+=(--full-if-older-than 2D) - else - # force a full backup once in a while - options+=(--full-if-older-than 30D) - fi + # TODO: create snapshots here if possible. Sadly that's really difficult so + # it will probably not be implemented - #export PASSPHRASE - HOME=/root duplicity \ - -v5 \ - --numeric-owner \ - --volsize 250 \ - --allow-source-mismatch \ - --asynchronous-upload \ - --no-encryption \ - "${options[@]}" "$@" "$src" "$dest" - - HOME=/root duplicity --force remove-older-than 120D "$dest" - #export PASSPHRASE="" + backup_borg / "backup:borg-$HOSTNAME" } backup_borg() { local src=$1 + local dst=$2 borg create \ -v \ @@ -123,9 +84,9 @@ backup_borg() { --stats \ --progress \ --exclude-from "$TMPDIR/exclude-list-borg" \ - "::backup-$(date "+%Y%m%d-%H%M%S")" "$src" + "$dst::backup-$(date "+%Y%m%d-%H%M%S")" "$src" - borg prune -v --keep-within 3m + borg prune -v --keep-within 6m "$dst" } ### support functions below ### -- cgit v1.2.3-24-g4f1b