Human memory is sometimes unreliable, so it is not always possible to answer in the same way to the configuration questions. Fortunately, this process can be automated using debconf utilities.

How to print configuration

Use Pipe driver to print configuration settings matched by the provided pattern to standard output.

$ sudo debconf-copydb configdb stdout \
    --config=Name:stdout                    \
    --config=Driver:Pipe                    \
    --config=InFd:none                      \
    --pattern='^shared/default-x-display-manager'
Name: shared/default-x-display-manager
Template: shared/default-x-display-manager
Value: slim
Owners: gdm3, slim
Flags: seen
Variables:
 choices = gdm3, slim

How to store configuration

Use File driver to store settings matched by provided pattern and in the specified file.

$ sudo debconf-copydb configdb partialdb \
    --config=Name:partialdb              \
    --config=Driver:File                 \
    --config=Filename:export.dat         \
    --pattern='^shared/default-x-display-manager'

How to import configuration

Import settings stored in the specified file (export.dat in this example).

$ sudo debconf-copydb importmedb configdb  \
    --config=Name:importmedb               \
    --config=Driver:File                   \
    --config=Filename:export.dat

Copy settings matched by provided pattern over SSH protocol to a different machine.

$ sudo debconf-copydb configdb pipe                      \
    --config=Name:pipe                                   \
    --config=Driver:Pipe                                 \
    --config=InFd:none                                   \
    --pattern='^shared/default-x-display-manager'      | \
        ssh remotemachine debconf-copydb pipe configdb   \
            --config=Name:pipe                           \
            --config=Driver:Pipe

Additional notes

Available databases are defined inside /etc/debconf.conf configuration file.

I use the above-mentioned techniques inside custom-built shell scripts altogether with the apt-offline utility to perform initial system setup and configuration using the method shown below.

[...]
debconf-copydb defaultdb configdb       \
                --config=Name:defaultdb \
                --config=Driver:File    \
                --config=Filename:defaultdb.dat

apt-offline install --allow-unauthenticated system_packages/debian-update.zip 
apt-offline install system_packages/debian-upgrade.zip 

apt-get -y upgrade

apt-offline install system_packages/debian-packages.zip

export DEBIAN_FRONTEND=noninteractive
apt-get -y install task-desktop openbox openbox-themes obconf slim obmenu
[...]

Read debconf-copydb, debconf and debconf.conf manual pages for more information.