Applies to: Uptime Kuma running on Raspberry Pi via Docker/Dockge.
Primary Error: SQLITE_CORRUPT: database disk image is malformed
1. Database Recovery Procedure
If Uptime Kuma fails to start and logs show a "database malformed" error, the SQLite internal structure is corrupted. Use a temporary Alpine container to repair it without installing local dependencies.
Step 1: Stop the Stack
In the Dockge UI, stop the Uptime Kuma container to release file locks.
Step 2: Run the Repair Command
Navigate to your stack folder (e.g., /opt/stacks/uptime-kuma) and run:
docker run --rm -v $(pwd):/data -w /data alpine:latest \
sh -c "apk add --no-cache sqlite && sqlite3 kuma.db '.recover' | sqlite3 kuma_new.db"
Step 3: Swap the Database Files
If kuma_new.db has a file size greater than 0, replace the broken database:
mv kuma.db kuma.db.broken
mv kuma_new.db kuma.db
chmod 666 kuma.db
2. Setting Data Retention (30-Day Limit)
To prevent the database from growing too large—which slows down the Pi and increases corruption risk—limit the history.
Log into Uptime Kuma.
Navigate to Settings > Monitor History.
Set Keep monitor history for X days to
30.Scroll to the bottom and click Save.
[!TIP] Why 30 days? On an SD card, every "write" operation has a cost. Limiting retention reduces the frequency of disk writes and keeps the database snappy.
3. Shrinking the Database (VACUUM)
Deleting records (Step 2) does not automatically reduce the file size on disk; it leaves "empty holes" in the file. To reclaim space:
Go to Settings > Monitor History.
Click the Shrink Database button.
Wait: The UI may become unresponsive for 1–2 minutes while the database is rebuilt.
Verify the file size has decreased using
ls -lh kuma.dbin the terminal.
4. Manual Backup Procedure
Before making major changes or updates, perform a manual "cold backup."
Stop the stack in Dockge.
Copy the file with a timestamp:
cp kuma.db kuma.db.backup_$(date +%F)Restart the stack.
5. Prevention Checklist for Raspberry Pi
Power: Use an official Raspberry Pi Power Supply to avoid "under-voltage" events.
Storage: Consider migrating from an SD Card to a USB SSD for better database reliability.
Export: Periodically use the Settings > Backup feature in the Kuma UI to download a
.jsoncopy of your monitors and settings.