Skip to content
This repository was archived by the owner on Jun 19, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions borgsnap
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# borgsnap - licensed under GPLv3. See the LICENSE file for additional
# details.
Expand Down Expand Up @@ -109,13 +109,13 @@ dobackup() {
echo "------ $(date) ------"
bind_dir="${OUT}/bind/${1}"
mkdir -p "$bind_dir"
mount --bind "${mount}/.zfs/snapshot/${2}" "$bind_dir"
mount -t ${MOUNT_FS_TYPE:-bind} "${mount}/.zfs/snapshot/${2}" "$bind_dir"
echo "Doing local backup of ${1}@${2}"
BORG_OPTS="--info --stats --compression lz4 --exclude-if-present .noborg"
borg create $BORG_OPTS "${borgdir}::${2}" "$bind_dir"
if [[ -n $rsyncdir ]]; then
echo "Doing rsync backup of ${1}@${2}"
borg create $BORG_OPTS --remote-path=borg1 "${rsyncdir}::${2}" "$bind_dir"
borg create $BORG_OPTS --remote-path=$REMOTE_BORG "${rsyncdir}::${2}" "$bind_dir"
fi
umount "$bind_dir"
}
Expand Down Expand Up @@ -143,7 +143,7 @@ purgeold() {
borg prune $BORG_OPTS "$borgdir"
if [[ -n $rsyncdir ]]; then
echo "Pruning rsync borg"
borg prune $BORG_OPTS --remote-path=borg1 "$rsyncdir"
borg prune $BORG_OPTS --remote-path=$REMOTE_BORG "$rsyncdir"
fi
fi
}
Expand All @@ -168,14 +168,14 @@ for i in $FS; do
if [[ ! -d $borgdir ]]; then
echo "Initializing borg $borgdir"
mkdir -p "$borgdir"
borg init "$borgdir"
borg init --encryption=keyfile "$borgdir"
if [[ -n $REMOTE ]]; then
echo "Initializing rsync $rsyncdir"
host=${REMOTE%:*}
dir=${REMOTE#*:}
ssh "$host" mkdir -p "$dir/$pool/$fs"
if [[ -n $rsyncdir ]]; then
borg init --remote-path=borg1 "$rsyncdir"
borg init --encryption=keyfile --remote-path=$REMOTE_BORG "$rsyncdir"
fi
fi
fi
Expand Down
1 change: 1 addition & 0 deletions sample.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FS="zroot/root zroot/home zdata/data"
OUT="/backup/borg"
REMOTE=""
PASS="/path/to/my/super/secret/myhost.key"
MOUNT_FS_TYPE="bind"
MONTH_KEEP=1
WEEK_KEEP=4
DAY_KEEP=7
2 changes: 2 additions & 0 deletions sample_rsync.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
FS="zroot/root zroot/home zdata/data"
OUT="/backup/borg"
REMOTE="XXXX@YYYY.rsync.net:myhost"
REMOTE_BORG="borg1"
PASS="/path/to/my/super/secret/myhost.key"
MOUNT_FS_TYPE="bind"
MONTH_KEEP=1
WEEK_KEEP=4
DAY_KEEP=7