From cc6feac775f15a091800a36a131d90fcaa25713d Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Wed, 23 May 2018 12:44:36 -0300 Subject: Support for local backups --- borger | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'borger') 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 } -- cgit v1.2.3