From eedb6325a935fcf3b5ab9de12d87b5e9f2e429d6 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 26 May 2018 10:10:20 -0300 Subject: Support for multiple configuration profiles --- borger | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'borger') 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 [--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 -- cgit v1.2.3