Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 29 Nov 2021 06:01:22 -0500
From:      Dennis Clarke via freebsd-current <freebsd-current@freebsd.org>
To:        FreeBSD Current <freebsd-current@freebsd.org>
Subject:   pkg sqlite database borked ( again ). How to restore?
Message-ID:  <4d9d5406-c257-e5cb-d237-d26889468f62@blastwave.org>

next in thread | raw e-mail | index | archive | help

I had another kernel panic on an AMD64 server. This has resulted in the
pkg database being messed up. Also I was running a QEMU instance for
aarch64 and that ended up with a messed up pkg database also.

I saw some docs in section 4.4.8. Restoring the Package Database here:

    https://docs.freebsd.org/en/books/handbook/ports/#pkgng-intro

However that does not work and issues a truely worthless error :

europa# uname -apKU
FreeBSD europa 14.0-CURRENT FreeBSD 14.0-CURRENT #6
main-n250839-be60d8f276f: Fri Nov 19 00:02:38 GMT 2021
root@europa:/usr/obj/usr/src/amd64.amd64/sys/GENERIC  amd64 amd64
1400042 1400042
europa#
europa# ls -lap /var/backups/pkg*
-rw-r--r--  1 root  wheel  2714084 Nov 29 03:04 /var/backups/pkg.sql.xz
-rw-r--r--  1 root  wheel  2714084 Nov 28 03:20 /var/backups/pkg.sql.xz.1
-rw-r--r--  1 root  wheel  2714084 Nov 27 03:03 /var/backups/pkg.sql.xz.2
-rw-r--r--  1 root  wheel  2714084 Nov 26 03:03 /var/backups/pkg.sql.xz.3
-rw-r--r--  1 root  wheel  2714084 Nov 25 03:29 /var/backups/pkg.sql.xz.4
-rw-r--r--  1 root  wheel  2712568 Nov 24 03:04 /var/backups/pkg.sql.xz.5
-rw-r--r--  1 root  wheel  2712568 Nov 23 03:03 /var/backups/pkg.sql.xz.6
-rw-r--r--  1 root  wheel  2711928 Nov 22 03:54 /var/backups/pkg.sql.xz.7
europa#

So I took a backup from there that looked reasonable :

europa# xz -dc /var/backups/pkg.sql.xz.3 > /var/db/pkg/local.sqlite.dump

europa#
europa# pkg backup -r /var/db/pkg/local.sqlite.dump
Restoring database:
Restoring: 100%
pkg: sqlite error while executing backup step in file backup.c:98: not
an error
pkg: sqlite error -- (null)
europa# echo $?
1
europa#

I don't know what to make of that mess.

Can I create a new blank sqlite3 database and then restore from that
dump file or is there a method that works better?

Also is there a blank sqlite3 database for pkg on the install media?

-- 
Dennis Clarke
RISC-V/SPARC/PPC/ARM/CISC
UNIX and Linux spoken
GreyBeard and suspenders optional



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4d9d5406-c257-e5cb-d237-d26889468f62>