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                      \
Name: shared/default-x-display-manager
Template: shared/default-x-display-manager
Value: slim
Owners: gdm3, slim
Flags: seen
 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         \

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                   \

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                           \

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    \

apt-offline install --allow-unauthenticated system_packages/ 
apt-offline install system_packages/ 

apt-get -y upgrade

apt-offline install system_packages/

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.