Skip to main content

Repairing Configuration Database SQLite3 Files

Repairing an SQLite3 configuration database for Access Server is a rare but occasionally necessary task. If you encounter an error indicating a malformed database, such as DatabaseError: database disk image is malformed, this topic will help you diagnose the issue and attempt a recovery.

  1. Ensure your server is stable and the hardware is functioning properly.

  2. Run diagnostics to check memory, disk health, and available disk space.

  1. Connect to your Access Server console and get root privileges.

  2. Halt the Access Server service to prevent further changes:

    service openvpnas stop
  3. Back up your database files before attempting any repairs:

    cd /usr/local/openvpn_as/etc/db/
    mkdir backup
    cp *.db ./backup
    • Now, you have files in the backup subfolder if needed.

      Important

      This is a simplified backup process done with a stopped Access Server. We recommend creating regular backups. Refer to this tutorial, which doesn't require stopping Access Server's service:

  1. Use SQLite3 to convert the damaged database into SQL commands and rebuild it.

  2. Attempt recovery on each of the four main database files.

    cd /usr/local/openvpn_as/etc/db/
    mv config.db config.db.backup
    sqlite3 config.db.backup .dump | sqlite3 config.db
    
    mv config_local.db config_local.db.backup
    sqlite3 config_local.db.backup .dump | sqlite3 config_local.db
    
    mv certs.db certs.db.backup
    sqlite3 certs.db.backup .dump | sqlite3 certs.db
    
    mv userprop.db userprop.db.backup
    sqlite3 userprop.db.backup .dump | sqlite3 userprop.db
    
    mv log.db log.db.backup
    sqlite3 log.db.backup .dump | sqlite3 log.db

    Tip

    If you have an issue with only one of the four database files, you can run the commands for that file only.

  • After running the recovery commands, restart the server and check functionality:

    service openvpnas restart
  1. Test the server to ensure the repair was successful.

  2. If the issues persist, ever to the backup files or contact us for support.