Browse Source

don't trash the database when upgrading (#112)

Thibault "bui" Koechlin 5 years ago
parent
commit
454e2850b5
1 changed files with 4 additions and 0 deletions
  1. 4 0
      wizard.sh

+ 4 - 0
wizard.sh

@@ -315,6 +315,8 @@ update_full() {
 
 
     log_info "Backing up existing configuration"
     log_info "Backing up existing configuration"
     ${CSCLI_BIN_INSTALLED} backup save ${BACKUP_DIR}
     ${CSCLI_BIN_INSTALLED} backup save ${BACKUP_DIR}
+    log_info "Saving default database content"
+    cp /var/lib/crowdsec/data/crowdsec.db ${BACKUP_DIR}/crowdsec.db
     log_info "Cleanup existing crowdsec configuration"
     log_info "Cleanup existing crowdsec configuration"
     uninstall_crowdsec
     uninstall_crowdsec
     log_info "Installing crowdsec"
     log_info "Installing crowdsec"
@@ -322,6 +324,8 @@ update_full() {
     log_info "Restoring configuration"
     log_info "Restoring configuration"
     ${CSCLI_BIN_INSTALLED} update
     ${CSCLI_BIN_INSTALLED} update
     ${CSCLI_BIN_INSTALLED} backup restore ${BACKUP_DIR}
     ${CSCLI_BIN_INSTALLED} backup restore ${BACKUP_DIR}
+    log_info "Restoring saved database"
+    cp ${BACKUP_DIR}/crowdsec.db /var/lib/crowdsec/data/crowdsec.db
     log_info "Finished, restarting"
     log_info "Finished, restarting"
     systemctl restart crowdsec || log_err "Failed to restart crowdsec"
     systemctl restart crowdsec || log_err "Failed to restart crowdsec"
 }
 }