Solved Deleted /var/db/pkg (was: big problem)

Please read from #6 onwards.
I have ufs file system.
I found in /usr/local/etc/periodic/daily/411.pkg-backup which is from June 10th
In /var/backups/ I have:
pkg.sql.zst from April 21 and pkg.sql.xz

And I still do not know how can I get /var/db/pkg and what was in.

pkg info shows me nothing.
 
Does that get setup when you do pkg bootstrap?
My directory /vard/db/pkg is empty
bootstrap installed pkg and pkg info show me pkg-2.7.5 Package manager
And now I have in /var/db/pkg/local.sqlite and diorectory /repos where are directories FreeBSD-ports and FreeBSD-ports-kmods
 
If pkg is actually installed, what does pkg upgrade -n do? That should run it may recreate the file, I don't know for sure
Code:
pkg upgrade -n
Updating FreeBSD-ports repository catalogue...
FreeBSD-ports repository is up to date.
Updating FreeBSD-ports-kmods repository catalogue...
FreeBSD-ports-kmods repository is up to date.
All repositories are up to date.
Checking for upgrades (1 candidates): 100%
Processing candidates (1 candidates): 100%
Checking integrity... done (0 conflicting)
Your packages are up to date.
 
What does "ls /var/db/pkg" show? I have about 6 files in mine.
I don't know exactly what the contents of pkg.sql.xz is but the thread that Charlie_ points to should help you restore.
 
What does "ls /var/db/pkg" show? I have about 6 files in mine.
I don't know exactly what the contents of pkg.sql.xz is but the thread that Charlie_ points to should help you restore.
vardbpkg.gif
 
Ok, so basically you've lost all your data about what is installed. I still think the contents of /var/backups/pkg.sql.xz will restore that but as I've said, I don't know how to do that, the thread pointed out in #3 should have instructions on what to do.
 
It seems you lost the package/file associatons but then how can pkg still know everything is up to date? It remembers the installed versions anyway?
 
What does "ls /var/db/pkg" show? I have about 6 files in mine.
I don't know exactly what the contents of pkg.sql.xz is but the thread that Charlie_ points to should help you restore.
In /var/backups I have what is on the picture. The last backup is from april. One *.xz and the othe *.zst. Which one is correct, please?
 
See if this helps:
 
See if this helps:
Looks like that work but are many checksum mismatch and didn't finish yet.. Can I run pkg upgrade -f?
 
I suppose you can though I haven't tried it. If the database is not consistent, I am not sure how well pkg upgrade -f will work. Note that it will reinstall all the packages. One thing you can try is to "pkg install -f" packages with checksum errors & iterate till pkg check -a is clean.

The key thing is to make sure you have a list of all the packages so in the worst case you can always start with a clean slate!
 
I suppose you can though I haven't tried it. If the database is not consistent, I am not sure how well pkg upgrade -f will work. Note that it will reinstall all the packages. One thing you can try is to "pkg install -f" packages with checksum errors & iterate till pkg check -a is clean.

The key thing is to make sure you have a list of all the packages so in the worst case you can always start with a clean slate!
Code:
 pkg check -ad
Checking all packages: 100%

I didn't pkg install -f but I need to check which apps i need to remove because I have 910 but before I had 840 :). But it is important that works.
Thank you very much.
 
pkg database is backed up by /usr/local/etc/periodic/daily/411.pkg-backup as a daily job.

So if you want to keep backup up-to-date as precise as possible, you'll need to keep your computer running over night when you did something (install, upgrade, delete) with ports/pkgs. (Even built / installed / deleted / reinstalled via ports, the information of the ports are recorded into pkg database. This would be usually done by creating temporary pkg and install it using pkg(8).)

Not sure it's rejected when running periodic(8) scripts from outside of the periodic system or not, as I've never actually tested.
 
Back
Top