---
title: Repairing Configuration Database SQLite3 Files
canonical: https://openvpn.net/as-docs/repair-config-db-sqlite3/
product: Access Server Docs
---

# 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.

## Step 1: Check the environment

1. Ensure your server is stable and the hardware is functioning properly.
2. Run diagnostics to check memory, disk health, and available disk space.

## Step 2: Stop Access Server and make backups

1. Connect to your Access Server console and get root privileges.
2. Halt the Access Server service to prevent further changes:

   ```
   systemctl stop openvpnas
   ```
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:
     >
     > - [Tutorial: How to Back Up Access Server Configuration](https://openvpn.net/as-docs/tutorials/tutorial--configuration-backup.md)

## Step 3: Run the recovery process

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.

## Step 4: Restart Access Server

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

   ```
   systemctl restart openvpnas
   ```

## Step 5: Test and verify

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](https://support.openvpn.com/).

---

Prev: [Configuration](https://openvpn.net/as-docs/configuration-troubleshooting.md)
Next: [Commonly Asked Technical Questions](https://openvpn.net/as-docs/common-technical-questions.md)
Index: https://openvpn.net/as-docs/llms.txt
