The upcoming release of Gentoo Build Publisher will have the ability to dump and restore builds to an archive. For a while I've wanted this feature but just never got around to it. The main reason that I wanted it is that when I find an issue on my "production" GBP instance, or another user has an issue with theirs, I want to be able to have the build(s) dumped and restore them on my development workstation for investigation.
The gbpcli
now understands two subcommands: dump
and restore
. These
subcommands are "server-only" mean they are only available from the GBP server
instance. The dump
subcommand can dump all the builds on the instance, just
a particular machine or machines, or a particular build or builds, or any
combination of those.
Then restoring is as simple as running gbp restore
:
At the time of this writing, it does not handle the condition of restoring builds that already exist on the GBP instance, however this will be worked out prior to the next release.
How the dump process works is a tar archive is created. Inside that tar
archive is another tar archive consisting of the "storage" for the given
build(s). By storage I mean all of the repos, binpkgs, and configuration for
given build. All of thee are stored in an inner tar archive called
storage.tar
. The reason for the single archive and not one archive per build
is to preserver the multiple hard links which span across builds (for a given
machine) but they will not be preserve across multiple archives.
After all of the storages are archived, the dump process then stores the
"records". This is the metadata stored for the builds in a database. This
information is serialized into JSON and stored in a single file,
records.json
.
That's pretty much it for the dump process. Similarly for the restore process,
we open the outer tar archive and then extract the contents of storage.tar
to the root of the instance's storage root. Then the records.json
file is
deserialized and loaded into the instance's database. Currently the restore
process is all-or-nothing. But in the future I may add the ability to filter
out what builds get restored.
2025-02-17: I've changed my mind. In all likelihood the dump & restore feature will be shipped as a seperate plugin for Gentoo Build Publisher.