Corrupt Database on Synology

I’ve been using Sonarr for a few months on my 1815+ NAS and it has been working great until the other day when the package just stopped running and won’t start again.

I’ve uninstalled the package and re-installed it which works, but gives me a blank install, and I don’t really want to have to start my configuration all over again as I have a couple hundred shows and a lot of time/effort into it. I did take a copy of the nzbdrone folder before I uninstalled it, even though the backup/restore guide doesn’t say to do so. Anyway, I ran the commands in the guide

rm -r /usr/local/nzbdrone/var/.config/NzbDrone/nzbdrone.db-*
cp -f /tmp/nzbdrone_backup/. /usr/local/nzbdrone/var/.config/NzbDrone/

but it failed as that /tmp directory did not exist. So I copied the contents of that folder from the backup I made earlier, edited the start-stop script to run as Auto, Chown’d the nzbdrone folder and restarted Sonarr… Now Sonarr won’t run again…

There is only 1 file in the logs directory; here is the tail of it

15-5-7 20:03:18.0|Trace|EventAggregator|ApplicationStartedEvent <- DownloadClientFactory
15-5-7 20:03:18.0|Trace|EventAggregator|ApplicationStartedEvent -> IndexerFactory
15-5-7 20:03:18.0|Debug|IndexerFactory|Initializing Providers. Count 12
15-5-7 20:03:18.0|Trace|EventAggregator|ApplicationStartedEvent <- IndexerFactory
15-5-7 20:03:18.0|Trace|EventAggregator|ApplicationStartedEvent -> ReconfigureLogging
15-5-7 20:03:21.7|Info|SceneMappingService|Updating Scene mappings
15-5-7 20:03:22.7|Info|HousekeepingService|Running housecleaning tasks
15-5-7 20:03:22.9|Info|Database|Vacuuming database
15-5-7 20:03:23.0|Info|Database|Database Compressed
15-5-7 20:03:29.2|Warn|GlobalExceptionHandlers|SignalR Heartbeat error.

Any help you can give to help me troubleshoot or restore my config would be very much appreciated.

Those logs don’t show any errors and show Sonarr running properly.

Changing the user may have done something though, why change the start-stop script?

Only thing changed in the script is to get it to run as user Auto instead of nzbdrone. Running as the default user is problematic due to permissions issues. Anyway, the working package was running as user Auto from day one so I’m pretty confident that’s not the issue.

I titled the thread as a corrupt database as when I tried the web ui shortly after the package stopped, I got an sql error, and copying the Db files back into a working package gives the same result.

Are the logs still showing a corrupt DB? You’d need to restore a backup to recover from that.

I’m not sure bc I don’t know where to find any other log files. There is only 1 file (nzbdrone.txt) in the logs folder and I already shared the tail… I can upload the whole file somewhere I guess if that would help?

Where would I find the backup file to restore from if I needed to do that? I know I had taken several backups in the past so going back to the latest one would be better than where I am now. I wasn’t able to take one when the crash happened as I couldn’t get into the UI.

They’re stored in the AppData folder in a backups folder (along side Sonarr’s DB).

I can’t find an AppData folder… Can you give me a full path to look in? Thanks

Tried some more troubleshooting… So with a clean install running, I took a manual backup. It seems all that does is zip up a copy of config.xml and nzbdrone.db. So from there, I stopped the package, deleted nzbdrone.db, copied in my old nzbdrone.db file, chown’d it to match the default nzbdrone user, and restarted the package. It seems that the db file was rejected as when I went into the UI, it was still just a blank database.

After that, I ran through the same procedure but with all the db files, nzbdrone.db and nzbdrone.db-* but it seems that the same thing happens.

I really just want to get back to a working copy of Sonarr… I put in a lot of time to get all of my shows listed etc. and don’t want to have to go through that all again.

Did you copy it to the correct location? You can double check in System: Status, specifically the AppData Directory.

Here is a screenshot from the settings page…
AppData Screenshot

I put the files in the following location which matches the AppData listing from the screenshot.
/volume2/@appstore/nzbdrone/var/.config/NzbDrone

Moss-Nas> cp /volume2/@appstore/nzbdrone.old/var/.config/NzbDrone/nzbdrone.db .
Moss-Nas> ll
drwxr-xr-x 4 nzbdrone root 4096 May 8 21:26 .
drwxr-xr-x 4 nzbdrone root 4096 May 8 21:13 …
drwxr-xr-x 3 nzbdrone users 4096 May 8 21:14 Backups
-rw-r–r-- 1 nzbdrone root 406 May 8 21:21 config.xml
drwxr-xr-x 2 nzbdrone users 4096 May 8 21:13 logs
-rw-r–r-- 1 nzbdrone users 1024 May 8 21:13 logs.db
-rw-r–r-- 1 nzbdrone users 32768 May 8 21:21 logs.db-shm
-rw-r–r-- 1 nzbdrone users 237928 May 8 21:21 logs.db-wal
-rw-r–r-- 1 root root 63488 May 8 21:26 nzbdrone.db
-rw-r–r-- 1 nzbdrone users 5 May 8 21:21 nzbdrone.pid
Moss-Nas> cp /volume2/@appstore/nzbdrone.old/var/.config/NzbDrone/nzbdrone.db-* .
Moss-Nas> ll
drwxr-xr-x 4 nzbdrone root 4096 May 8 21:26 .
drwxr-xr-x 4 nzbdrone root 4096 May 8 21:13 …
drwxr-xr-x 3 nzbdrone users 4096 May 8 21:14 Backups
-rw-r–r-- 1 nzbdrone root 406 May 8 21:21 config.xml
drwxr-xr-x 2 nzbdrone users 4096 May 8 21:13 logs
-rw-r–r-- 1 nzbdrone users 1024 May 8 21:13 logs.db
-rw-r–r-- 1 nzbdrone users 32768 May 8 21:21 logs.db-shm
-rw-r–r-- 1 nzbdrone users 237928 May 8 21:21 logs.db-wal
-rw-r–r-- 1 root root 63488 May 8 21:26 nzbdrone.db
-rw-r–r-- 1 root root 32768 May 8 21:26 nzbdrone.db-shm
-rw-r–r-- 1 root root 276704 May 8 21:26 nzbdrone.db-wal
-rw-r–r-- 1 nzbdrone users 5 May 8 21:21 nzbdrone.pid
Moss-Nas> chown nzbdrone:users *
Moss-Nas> ll
drwxr-xr-x 4 nzbdrone root 4096 May 8 21:26 .
drwxr-xr-x 4 nzbdrone root 4096 May 8 21:13 …
drwxr-xr-x 3 nzbdrone users 4096 May 8 21:14 Backups
-rw-r–r-- 1 nzbdrone users 406 May 8 21:21 config.xml
drwxr-xr-x 2 nzbdrone users 4096 May 8 21:13 logs
-rw-r–r-- 1 nzbdrone users 1024 May 8 21:13 logs.db
-rw-r–r-- 1 nzbdrone users 32768 May 8 21:21 logs.db-shm
-rw-r–r-- 1 nzbdrone users 237928 May 8 21:21 logs.db-wal
-rw-r–r-- 1 nzbdrone users 63488 May 8 21:26 nzbdrone.db
-rw-r–r-- 1 nzbdrone users 32768 May 8 21:26 nzbdrone.db-shm
-rw-r–r-- 1 nzbdrone users 276704 May 8 21:26 nzbdrone.db-wal
-rw-r–r-- 1 nzbdrone users 5 May 8 21:21 nzbdrone.pid
Moss-Nas>
Moss-Nas> ll
drwxr-xr-x 4 nzbdrone root 4096 May 8 21:27 .
drwxr-xr-x 4 nzbdrone root 4096 May 8 21:13 …
drwxr-xr-x 3 nzbdrone users 4096 May 8 21:14 Backups
-rw-r–r-- 1 nzbdrone users 406 May 8 21:27 config.xml
drwxr-xr-x 2 nzbdrone users 4096 May 8 21:13 logs
-rw-r–r-- 1 nzbdrone users 1024 May 8 21:13 logs.db
-rw-r–r-- 1 nzbdrone users 32768 May 8 21:27 logs.db-shm
-rw-r–r-- 1 nzbdrone users 276704 May 8 21:27 logs.db-wal
-rw-r–r-- 1 nzbdrone users 198656 May 8 21:27 nzbdrone.db
-rw-r–r-- 1 nzbdrone users 32768 May 8 21:27 nzbdrone.db-shm
-rw-r–r-- 1 nzbdrone users 216968 May 8 21:27 nzbdrone.db-wal
-rw-r–r-- 1 nzbdrone users 5 May 8 21:27 nzbdrone.pid
Moss-Nas>

The last LL is after I started the package again. You can see that the file size has increased a lot, not sure if that means anything or not.

What is the size shown in, bytes or KB?

Have you tried without the nzbdrone.db-shm and nzbdrone.db-wal files?

Delete all the log.db files, they aren’t of any use. Is there anything in the log files?

The old DB file was 62KB, after copying it into the working folder and restarting Sonarr, it increased to 201KB.

I just tried deleting the nzbdrone.db file, the nzbdrone.db-shm & wal files, and all the logs.db files. I also deleted the nzbdrone.txt file in the logs folder to get a clean log file. I copied in only the old nzbdrone.db file, chown’d it to be owned by user nzbdrone and restarted Sonarr… This time it only increased to 71KB but I still have an empty database when I go into the Sonarr UI.

Here is a copy of the new nzbdrone.txt log file.

https://drive.google.com/open?id=0B3926H-Ed3abc0dpOVRYdXduMm8&authuser=0

71KB would be an empty DB. I’d expect it in the megabytes if it had all the series loaded. It sounds like the file you have isn’t a backup of a full database, but of an empty one.

Well I appreciate you helping my try to troubleshoot this but it basically looks like I’m screwed…

Like I said, I just logged in one day to find Sonarr not running, and wouldn’t restart and now it looks like it wiped itself and my backups out whenever it crashed - which is pretty disconcerting. I guess this gives me a reason to go evaluate SickRage since I will have to manually rebuild the database either way.

Unfortunately Synology removes all the app data for a package when it is uninstalled, which looks like was one of the first things that was done to try to resolve it.

I’ve uninstalled the package and re-installed it which works

I agree that it seems that my install somehow became defaulted but I copied the install directory BEFORE I uninstalled it.

I did take a copy of the nzbdrone folder before I uninstalled it, even though the backup/restore guide doesn’t say to do so.

There really should be an option to place backups in a custom backup location however.

Right, I wasn’t just dreaming that you had a copy at some point. Do you still have the folder with all the backups?

Definitely, its something we want to do, but doesn’t help if it wasn’t set (which would be the case for a lot of people).

No, it seems like the whole thing was erroneously wiped, which explains why I couldn’t even find the location of the backups (both manual and automatic), that I knew I had taken in the past. I see now, on the clean install, that the Backups folder exists in the same location as the logs folder but there was no Backups folder in the copy I took before uninstalling.

Are there plans to implement a custom ‘backups’ location? I think that would have saved me, and it would also allow me to more easily write out a copy to another system or offsite the files.

It would also be good to allow for a custom schedule for taking backups. I know there is the option to take a manual backup, but I would rather be able to tell the system to just take an automatic backup every day, especially during the bulk of the setup. Weekly backups would be more appropriate once you are mostly finished with your setup.

Yes, https://github.com/Sonarr/Sonarr/issues/476