Does pkg backup still exist?

And you can reference the following commit in https://github.com/freebsd/pkg:
Code:
commit eea1a990eb1187a408811534a5060e58074a9044
Author: Baptiste Daroussin <bapt@FreeBSD.org>
Date:   Tue Oct 4 17:02:13 2022 +0200

    backup: remove the backup command which was confusing

    backup and backup -r was basically replicating the db, while we now
    prefer a real sql dump.

    with the backup command backuping a corrupted db will succesfully
    backup it and pkg backup -r will sucessfully restore a corrupted db.
    Making its usage quite useless.
 
Thank you getopt and yuripv79! I opened PR 271534 as suggested.

I currently use ZFS boot environments to safely proceed with a pkg upgrade. Would you advise any other steps or methods since pkg backup isn't available? To be honest it is not very clear to me what the author of the previously mentioned commit means by "we now prefer a real sql dump".
 
pkg backup isn't available?
This is independent a pkg-upgrade(8), now, to manually create a pkg database backup one must execute sh /usr/local/etc/periodic/daily/411.pkg-backup. This will create under /var/backups/ a pkg.sql.xz file and rename the previouse pkg database backups.

Otherwise a daily periodic cron job is run, IF the machine is running at 3 o'clock in the morning, local time.
/etc/crontab
Code:
# Perform daily/weekly/monthly maintenance.
1       3       *       *       *       root    periodic daily

To be honest it is not very clear to me what the author of the previously mentioned commit means by "we now prefer a real sql dump".

For a novice in shell scripting it's hard to interpret (like me, I hardly understand it myself), see /usr/local/etc/periodic/daily/411.pkg-backup for sql dump.

In short
Code:
do_dump() {
         ...
         ${pkgcmd} ${pkgargs} shell .dump
}

backup_pkg() {
        ...
        if do_dump | xz -c > ${bak_file}; then
        ...
        ...
        bak="${daily_backup_pkg_dir:-/var/backups}"
        bak_file="${bak}/pkg.sql.xz"
and
Code:
 % pkg shell .help | grep .dump
.dump ?OBJECTS?          Render database content as SQL
 
Thank you once again T-Daemon for the clear and detailed information!

his is independent a pkg-upgrade(8)
It has taken me quite a bit of reading to get an idea of the relation between installed packages and pkg's database. I must say that I found Thread 64361 quite useful in that respect.

do_dump() { ... ${pkgcmd} ${pkgargs} shell .dump }
Cool, so this is what actually "triggers" pkg's database backup.

I'm guessing that Baptiste Daroussin's commit message about preferring a real sql dump has to do with what they say in the sqlite documentation about the sqlite .dump command:
".dump" stops when the first sign of corruption is encountered.
 
Back
Top