summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2020-01-19 22:39:04 +0100
committerFlorian Pritz <bluewind@xinu.at>2020-01-19 22:39:44 +0100
commit281417b03bb92754340d41f620b70a8270120980 (patch)
treea0c734b8a3b0878afd9234d49d9dfd637af52fd8
parent78d312c6a4f51886e7273600f81dd978b5a18aee (diff)
downloadbin-281417b03bb92754340d41f620b70a8270120980.tar.gz
bin-281417b03bb92754340d41f620b70a8270120980.tar.xz
backup.sh: Support partial backups
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rwxr-xr-xbackup.sh25
1 files changed, 19 insertions, 6 deletions
diff --git a/backup.sh b/backup.sh
index cbaaf29..dd30db3 100755
--- a/backup.sh
+++ b/backup.sh
@@ -11,7 +11,7 @@
# - If you want, increase the max_segment_size in
# ssh://backup/borg-$HOSTNAME/config from the default 5MiB
#
-# Copyright ©2014-2017 Florian Pritz <bluewind@xinu.at>
+# Copyright ©2014-2019 Florian Pritz <bluewind@xinu.at>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -77,8 +77,19 @@ main() {
exclude_mountpoints
echo "$excludeList" > "$TMPDIR/exclude-list-borg"
+ source_paths=(/)
+ backup_prefix="backup"
+
+ if [[ $# -gt 0 ]]; then
+ source_paths=()
+ backup_prefix="partial"
+ for path in "$@"; do
+ source_paths+=("$(realpath "$path")")
+ done
+ fi
+
run_if_exists pre_backup
- backup_borg / "$borg_repo"
+ backup_borg "$backup_prefix" "$borg_repo" "${source_paths[@]}"
run_if_exists post_backup
}
@@ -107,8 +118,9 @@ post_backup() {
}
backup_borg() {
- local src=$1
- local dst=$2
+ local backup_prefix=$1; shift
+ local dst=$1; shift
+ local src=("$@")
local -a options=(
--verbose
--numeric-owner
@@ -120,8 +132,9 @@ backup_borg() {
options+=(--progress --stats)
fi
- borg create "${options[@]}" "$dst::backup-$(date "+%Y%m%d-%H%M%S")" "$src"
- borg prune --keep-within 7d --keep-daily 7 --keep-weekly 12 --keep-monthly 6 --keep-yearly 0 -v "$dst"
+ borg create "${options[@]}" "$dst::$backup_prefix-$(date "+%Y%m%d-%H%M%S")" "${src[@]}"
+ borg prune --prefix "backup-" --keep-within 7d --keep-daily 7 --keep-weekly 12 --keep-monthly 6 --keep-yearly 0 -v "$dst"
+ borg prune --prefix "partial-" --keep-within 7d --keep-daily 7 --keep-weekly 12 --keep-monthly 6 --keep-yearly 0 -v "$dst"
}
### support functions below ###