diff options
Diffstat (limited to 'borger')
-rwxr-xr-x | borger | 27 |
1 files changed, 21 insertions, 6 deletions
@@ -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 } |