]> gitweb.fluxo.info Git - borger.git/commitdiff
Support for multiple configuration profiles
authorSilvio Rhatto <rhatto@riseup.net>
Sat, 26 May 2018 13:10:20 +0000 (10:10 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sat, 26 May 2018 13:10:20 +0000 (10:10 -0300)
README.md
borger

index 93195089172d6bfde3c49146ba82cb3e5f9d3a9f..ede99ca13b2d6e18c5a3c50eb485b8fdb0281d44 100644 (file)
--- 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 881fa0398fffaa948e6f2d1db303b70d9f51f6ac..8fe8e6de25efa9969f55cbeab0bd75e2b610e676 100755 (executable)
--- 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