Here's a nice-to-have idea.
If we want to get fancy and crunch down on space usage, the backup package could contain just the files that differ between old and new versions.
More complex than it seems. If initially package bar-1.00 depends on foo-1.00, and after update we have bar-2.00 depends on foo-2.00, then reverting the foo-1.00 -> foo-2.00 update implies reverting the bar-1.00 to bar-2.00 update and vice-versa.
This is partially implemented by the pkg-plugins-zfssnap plugin which creates a ZFS snapshot before taking any install/deinstall actions.
On the other hand it would be really nice to have a native "history" command in pkg which does this.
The logging table could also be a separate sqlite db, e.g. /var/db/history.sqlite in order to keep the local.sqlite small in size for doing backups and restore for example.
Issue #359 probably could be implemented as part of this one as well.