Re: Recover from a corrupt pkg DB

From: Tatsuki Makino <tatsuki_makino_at_hotmail.com>
Date: Tue, 30 Aug 2022 21:19:01 UTC
Hello.

I also just recently unlinked /var/db/pkg/local.sqlite to a place where it cannot be traced from the /var file system :)
To recover from that, there should already be a backup that others have mentioned, in which case the following command is all that is needed to restore it.

xzcat /var/backups/pkg.sql.xz | pkg shell

Now all that is left is to re-install the port that was installed after that backup was made, and you will most likely be back to normal.
After the backup is made, if the port tree is updated and there are any plist changes, no :)

Regards.