# Jellyfin

# Fix Jellyfin Database (upgrade from 10.11.11 to 12.1)

I had a corrupted Database, I took these steps to fix it. Make backups:

```
systemctl stop jellyfin
```

```
apt install sqlite3
cd /var/lib/jellyfin/data
cp jellyfin.db jellyfin.db.bak
sqlite3 jellyfin.db ".recover" | sqlite3 jellyfin.db.recovered
sqlite3 jellyfin.db.recovered "PRAGMA integrity_check;"
```
The check should return OK. If it outputs rows, you have to delete them:
(Make sure to delete your own rows and not just copy pasting mine)

```
DELETE FROM BaseItemProviders WHERE rowid = 45789;

DELETE FROM BaseItemProviders
WHERE ItemId NOT IN (SELECT Id FROM BaseItems)
   OR ItemId GLOB '*[!0-9A-Fa-f-]*';
```
run the check again
```
PRAGMA integrity_check;
```

it should return OK, if it does type `.quit`

Then I removed the encoding.xml
```
mv /etc/jellyfin/encoding.xml /etc/jellyfin/encoding.xml.old`
```
Then I upgraded jellyfin
```
apt update && apt dist-upgrade -y
```
Now the upgrade goes as intended but takes a while