summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 ###