database disk image is malformed

Ryan Schmidt ryandesign at
Fri Mar 27 23:52:00 UTC 2020

On Mar 27, 2020, at 18:47, Richard L. Hamilton wrote:

> Why can't there be at least a way to back up the database

That has been suggested here:

> and perhaps maintain a log of changes made since the last update, so that the database could be restored and brought up to date?
> So if for example one does port echo outdated | wc -l and the result is at least some size, one might choose  to back up, do the updates, and back up again; but if it's less, one might not bother.
> Worst case then would be reinstalling what was in the log (if there was some question of corruption other than just the database), rather than everything.
> I don't know how one backs up SQLite databases (other than copying the underlying file when it's inacttve and healthy), and I don't much know tcl. But it doesn't seem that it should be  all that difficult.  What am I missing?

The database is supposed to be reliable. I don't think we want to be in the business of second-guessing that assumption and building reliability layers on top of what is already supposed to be a reliable database. If the database is unreliable due to a bug in the database software, fix the database software. If it's unreliable due to hardware failure, fix the hardware.

Just backing up the database isn't super useful. The database is supposed to be consistent with the state of the rest of the disk: for example, if you install and activate a port, that's not only recorded in the registry but is also reflected in the files that are installed under /opt/local. If you restore an earlier version of the database, now it's inconsistent with what's on your disk, and MacPorts won't know that, so you'll run into problems.

More information about the macports-users mailing list