Bug 256886 - ports-mgmt/pkg pkg backup -r fails to restore local.sqlite
Summary: ports-mgmt/pkg pkg backup -r fails to restore local.sqlite
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-pkg (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-06-29 13:34 UTC by eimar.koort
Modified: 2021-06-29 13:34 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (pkg)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description eimar.koort 2021-06-29 13:34:51 UTC
When using "pkg backup" to create backup file from installed packages and later trying to restore, it fails. Backup itself works. Restore part fails.


root@fbsd:~ # uname -a
FreeBSD fbsd 13.0-RELEASE FreeBSD 13.0-RELEASE #0 releng/13.0-n244733-ea31abc261f: Fri Apr  9 04:24:09 UTC 2021     root@releng1.nyi.freebsd.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC  amd64

root@fbsd:~ # pkg info
libevent-2.1.12                API for executing callback functions on events or timeouts
pkg-1.16.3                     Package manager
tmux-3.1c                      Terminal Multiplexer
root@fbsd:~ # cp /var/db/pkg/local.sqlite /var/db/pkg/local.sqlite_bak 
root@fbsd:~ # pkg backup -d pkg_backup.dump 
Dumping database:
Backing up: 100%   

root@fbsd:~ # rm /var/db/pkg/local.sqlite
root@fbsd:~ # cp pkg_backup.dump /var/db/pkg/local.sqlite 
root@fbsd:~ # pkg info
libevent-2.1.12                API for executing callback functions on events or timeouts
pkg-1.16.3                     Package manager
tmux-3.1c                      Terminal Multiplexer

So the backup file itself is OK. Now trying to use "restore":

root@fbsd:~ # pkg backup -r pkg_backup.dump 
Restoring database:
Restoring: 100%
root@fbsd:~ # pkg info
pkg: sqlite error while executing ALTER TABLE packages ADD licenselogic INTEGER NOT NULL DEFAULT(1); in file pkgdb.c:2489: no such table: packages
root@fbsd:~ # ls -la /var/db/pkg
total 32084
drwxr-xr-x   2 root  wheel         7 Jun 29 16:08 .
drwxr-xr-x  19 root  wheel        27 May  8 14:50 ..
-rw-r--r--   1 root  wheel       158 Jun 29 16:02 FreeBSD.meta
-rw-r--r--   1 root  wheel     20480 Jun 29 16:08 local.sqlite
-rw-r--r--   1 root  wheel    405504 Jun 29 16:08 local.sqlite_bak
-rw-r--r--   1 root  wheel         0 Jun 29 16:08 pkg_backup.dump
-rw-r--r--   1 root  wheel  50925568 Jun 29 07:39 repo-FreeBSD.sqlite