Re: Recover from a corrupt pkg DB

From: Pete Wright <pete_at_nomadlogic.org>
Date: Tue, 30 Aug 2022 17:26:13 UTC
On Tue, Aug 30, 2022 at 09:36:52AM -0700, Kevin Oberman wrote:
> I had a crash while building ffmpeg on a new system. The build had not
> begun, so I don't think ffmpeg is really an issue. portmaster(8) was
> walking the dependency tree when the system panicked and, after a reboot
> and full fsck, I get the error:
> pkg: sqlite error while executing PRAGMA user_version; in file
> pkgdb.c:2357: database disk image is malformed
> 
> Is there any way to rebuild the DB or, if not, how do I remove it and start
> from scratch?

I ran into a similar issue a while back, I discovered I was able to
recover by using one of the automated backups generated at:
/var/backups/pkg.sql.xz*

I can't remember the details, but I think it involved replacing
repo-FreeBSD.sqlite in /var/db/pkg/.

hope this helps,
-pete

-- 
Pete Wright
pete@nomadlogic.org