Save sonarr.db cron

Sonarr version (exact version): 3.0.3.928
Mono version (if Sonarr is not running on Windows): 6.10.0.104
OS: Ubuntu 20.04 desktop
Debug logs:
Description of issue: database disk image is malformed database disk image is malformed

I had a catastrophe in the OS and had to restore it via Clonezilla. I updated the Sonarr to its current version, stopped its service, copied the current version of sonarr.db to /var/lib/sonarr and restarted the service. When I did, I got the message, ‘database disk image is malformed database disk image is malformed’.

sqlite3 sonarr.db “.dump” | sqlite3 new.db
Error: near line 9195: NOT NULL constraint failed: Commands.Trigger
Error: near line 9196: NOT NULL constraint failed: Commands.Trigger
Error: near line 9197: NOT NULL constraint failed: Commands.Trigger

Nightly I had saved both config.xml and sonarr.db to an archive. Now I must assume that I cannot do this because it may be updating?

If I still want to do this, would it help if I were to stop the sonarr.service? Is this safe and will it prevent database corruption?

Sonarr has a built-in backup mechanism, use the output from that. Capturing the Sonarr DB directly while it’s in use is going to have mixed results and stopping the service is unnecessary if you use the existing backup file.

What do I do if I want a scheduled daily backup?

You can use sonarr’s api in a cron job I suppose: https://github.com/Sonarr/Sonarr/wiki/Command#backup

I tried but perhaps incorrectly? It says I’m Unauthorized.

image

You need to pass your sonarr’s api key, it’s all in the wiki…

A little better, but no luck.

image

but http://192.168.10.20:8989/api/system/status?apikey=someApiKey

did return a list of all backups.

Scroll to the top of that page. It’s not /api/Backup to ask sonarr to create a backup… :wink:

Thirrian, your didacticism is over my head.

If you know how to do it, I’d appreciate if you would list the url.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.