I recently posted a tutorial on the
kdb import command. Well I also wanted to go over it’s sibling function,
kdb export. These two commands work very similarly, but there are some differences.
First of all, the command to use kdb export is:
kdb export [options] source [format]
In this command,
source is the root key of which Keys should be exported. For instance, kdb export system/export would export all the keys below system/export. Additionally, this command exports keys under the system/elektra directory by default. It does this so that information about the keys stored under this directory will be included if the Keys are later imported into an Elektra Key Database. This command export Keys to stdout to store them into the Elektra Key Database. Typically, the export command is used with redirection to write the Keys to a file.
As we discussed already, the
format argument can be a very powerful option to use with kdb export. Just like with
kdb import the format argument allows a user to specify which plug-in is used to export the Keys from the Key Database. The user can specify any storage plug-in to serve as the format for the exported Keys. For instance, if a user mounted their hosts file to system/hosts using
kdb mount /etc/hosts system/hosts hosts they would be able to export these Keys using the hosts format by using the command
kdb export system/hosts hosts > hosts.ecf. This command would essentially create a backup of their current /etc/hosts file in a valid format for /etc/hosts.
If no format is specified, the format
dump will be used instead. The dump format is the standard way of expressing Keys and all their relevant information. This format is intended to be used only within Elektra. The dump format is a good means of backing up Keys from the Key Database for use with Elektra later such as reimporting them later. As of this writing, dump is the only way to fully preserve all parts of the KeySet.
The kdb export command takes one special option, but it’s different than the one for
kdb import, that option is:
-E --without-elektra which omits the system/elektra directory of keys
An example of using the
kdb export is as follows:
kdb export system/backup > backup.ecf
This command would export all keys stored under system/backup, along with relevant Keys in system/elektra, into a file called backup.ecf.
As you can see, the
kdb export command is a very useful tool just like it’s sibling,
kdb import. If you haven’t yet, please go read the tutorial I wrote for
kdb import because these two commands are best used together and can enable some really great features of Elektra.
Ian S. Donnelly