GNU Mailutils Manual (split by node):   Section:   Chapter:FastBack: Programs   Up: mailutils dbm   FastForward: Libraries   Contents: Table of ContentsIndex: Function Index

3.20.12.1 Create a Database

The create subcommand and its synonym load instruct the tool to create a new database:

mailutils dbm create file.db

If the argument file already exists, it will be truncated prior to adding new records to it.

The data to populate the database with are read from the standard input. The mailutils dbm command supports several formats for these data, which are discussed later. In the simplest case (a so called ‘format 0.0’) each input line must consist of two fields separated by any amount of whitespace. The first field is treated as a key and the second one as the corresponding value.

The usual way to read data from a file is, of course, by redirecting the file to the standard input as in:

mailutils dbm create file.db < input.txt

There is also a special option for that purpose: --file (-f). Thus, the following command is equivalent to the one above:

mailutils dbm create --file input.txt file.db 

The --file option has the advantage that it allows, in conjunction with another options, for copying input file metadata (owner UID, GID and file mode) to the created database. For example, the following command ensures that the created database file will have the same metadata as the input file:

mailutils dbm create --file input.txt --copy-permissions file.db

The --copy-permissions (-P) option is the one that does the job.

There are also other ways to control mode and ownership of the created database, which are described below.

More advanced dump formats (e.g. ‘version 1.0’ format) carry additional information about the file, including its original name, ownership and mode. If input is in one of these formats, the file name argument becomes optional. If it is not supplied, the name stored in the input stream will be used. For example, supposing that the file users.dump is in format 1.0, the following command suffices to restore the original filename, ownership, mode and, of course, data:

mailutils dbm create --file users.dump

GNU Mailutils Manual (split by node):   Section:   Chapter:FastBack: Programs   Up: mailutils dbm   FastForward: Libraries   Contents: Table of ContentsIndex: Function Index