aboutsummaryrefslogtreecommitdiff
path: root/borger
diff options
context:
space:
mode:
Diffstat (limited to 'borger')
-rwxr-xr-xborger27
1 files changed, 21 insertions, 6 deletions
diff --git a/borger b/borger
index 2148986..0b1ac29 100755
--- a/borger
+++ b/borger
@@ -88,14 +88,29 @@ function borger_trap {
# Initialize
function borger_init {
- if ! ssh $SSH_SERVER -p $SSH_PORT test -f $BORG_REPO_DIR/config; then
- info "Initializing borg repository at $BORG_REPO..."
- borg init --encryption=$encryption $BORG_REPO
+ if [ ! -z "$SSH_SERVER" ]; then
+ # Remote backup over SSH
+ if ! ssh $SSH_SERVER -p $SSH_PORT test -f $BORG_REPO_DIR/config; then
+ info "Initializing borg repository at $BORG_REPO..."
+ borg init --encryption=$encryption $BORG_REPO
- init_exit=$?
+ init_exit=$?
- if [ "$init_exit" != "0" ]; then
- fatal "Error initializing repository"
+ if [ "$init_exit" != "0" ]; then
+ fatal "Error initializing repository"
+ fi
+ fi
+ else
+ # Local backup
+ if [ ! -f "$BORG_REPO/config" ]; then
+ info "Initializing borg repository at $BORG_REPO..."
+ borg init --encryption=$encryption $BORG_REPO
+
+ init_exit=$?
+
+ if [ "$init_exit" != "0" ]; then
+ fatal "Error initializing repository"
+ fi
fi
fi
}