aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2018-05-26 10:10:20 -0300
committerSilvio Rhatto <rhatto@riseup.net>2018-05-26 10:10:20 -0300
commiteedb6325a935fcf3b5ab9de12d87b5e9f2e429d6 (patch)
treea57f5d919a959408cf522ed756ec3f9061d682fe
parent50d5e5743dc94945f32c916ee3b37356d7a6b8af (diff)
downloadborger-eedb6325a935fcf3b5ab9de12d87b5e9f2e429d6.tar.gz
borger-eedb6325a935fcf3b5ab9de12d87b5e9f2e429d6.tar.bz2
Support for multiple configuration profiles
-rw-r--r--README.md14
-rwxr-xr-xborger28
2 files changed, 35 insertions, 7 deletions
diff --git a/README.md b/README.md
index 9319508..ede99ca 100644
--- a/README.md
+++ b/README.md
@@ -77,6 +77,20 @@ As simply as
borger servername --list
borger mydisk --list
+# Multiple configuration profiles
+
+You can process multiple backup destionation in the same command by placing each
+configuration in a subfolder of `~/.config/borger`, like `~/.config/borger/default/servername`
+and `~/.config/borger/default/mydisk` and invoking both using commands like
+
+ borger default
+ borger default --list
+ borger default --continuous
+
+Each config could even be a symbolic links to other configs, so you can build different
+backup profiles for different situations, eg. when your laptop is at home, office or if you're
+backing up to multiple external drives at the same time.
+
# WARNING
Borger uses `keyfile` encrytion by default. That means **you should backup your keyfile**
diff --git a/borger b/borger
index 881fa03..8fe8e6d 100755
--- a/borger
+++ b/borger
@@ -27,6 +27,7 @@ function fatal {
exit 1;
}
+# Display usage
function borger_usage {
echo "usage: $BASENAME <destination> [--continuous|--list]"
echo -n "available destinations from $BASE_CONFIG: "
@@ -34,8 +35,25 @@ function borger_usage {
exit 1
}
-# Config
+# Process configuration
function borger_config {
+ if [ ! -e "$CONFIG" ]; then
+ fatal "No such config $CONFIG"
+ elif [ -d "$CONFIG" ]; then
+ info "Multiple destination \"$DESTINATION\" found. Processing each subconfig..."
+
+ # Config is a folder, so we iterate over all items
+ # and call borger for each config
+ for config in `ls $CONFIG`; do
+ info "Calling borger for $DESTINATION/$config..."
+ $FULLNAME $DESTINATION/$config $OPTION
+ done
+
+ # Since we dispatched everything to subprocesses,
+ # there's nothing to do here.
+ exit
+ fi
+
# Ensure we have an username
if [ -z "$USER" ]; then
USER="`whoami`"
@@ -56,11 +74,7 @@ function borger_config {
PLACEHOLDER="{user}"
INTERVAL="1h"
- if [ -e "$CONFIG" ] ; then
- source $CONFIG
- else
- fatal "No such config $CONFIG"
- fi
+ source $CONFIG
# Setting this, so the repo does not need to be given on the commandline:
if [ -z "$BORG_REPO" ]; then
@@ -187,7 +201,7 @@ elif [ -z "$OPTION" ]; then
borger_run
elif [ "$OPTION" == "--list" ]; then
borger_config
- borger_check
+ borger_list
elif [ "$OPTION" == "--continuous" ]; then
borger_config