
tdbbackup Command in Linux
The tdbbackup command in Linux backs up and validates the integrity of Samba .tdb files. These .tdb files are commonly used by Samba for storing persistent states, like user sessions, locking information, or configuration.
Table of Contents
Here is a comprehensive guide to the options available with the tdbbackup command −
- Installation of tdbbackup Command
- Syntax of tdbbackup Command
- tdbbackup Command Options
- Examples of tdbbackup Command in Linux
Installation of tdbbackup Command
The tdbbackup command may not be installed by default on some Linux distributions. To install it on Ubuntu, Kali Linux, Raspberry Pi OS, Debian, and other Debian-based distributions, use the following command −
sudo apt install tdb-tools
To install it on Arch Linux, use the command given below −
sudo pacman -S tdb
For Alpine Linux, use −
sudo apk add tdb
To install tdbbackup on Fedora, use the following command −
sudo dnf install tdb-tools
To verify the installation of the tdbbackup command, check its binary path −
which tdbbackup

Syntax of tdbbackup Command
The syntax of the tdbbackup command in Linux is as follows −
tdbbackup [options] <fnameâ¦>
In the above syntax, the [options] field is used to specify the options to change the commandâs output. These options are listed in the next section. The <fnameâ¦> field is used to specify one or more .tdb file names to process.
tdbbackup Command Options
The options of the Linux tdbbackup command are listed below −
Option | Description |
---|---|
-h | To display a help message. |
-s suffix | To set the backup suffix. |
-v | To enable verification mode (restores from backup if corruption is detected). |
-n hashsize | To set the new hash size for the backup. |
-l | To open without locking to backup mutex dbs |
-r | To open with read-only locking. |
Examples of tdbbackup Command in Linux
This section explores how to use the tdbbackup command in Linux with examples −
- Creating a Backup of a tdb File
- Setting a Backup Suffix
- Checking tdb File for Damage
- Setting Hash Table Size for Backup
- Open with Read-Only Locking
- Skipping Locking during Backup
- Displaying Usage Help
Creating a Backup of a tdb File
To create a backup of a tdb file, use the tdbbackup command followed by the filename −
tdbbackup share_info.tdb

This command creates a backup file in the same directory.
Note that the tdb files are generally located in /var/lib/samba, or /run/samba directories.
Setting a Backup Suffix
To set a custom backup file suffix, use the -s option −
tdbbackup -s backup share_info.tdb

The above command creates a backup named store.tdb.backup instead of the default store.tdb.bak.
Checking tdb File for Damage
To check the file integrity and restore from the backup if corruption is found, use the -v option −
tdbbackup -v share_info.tdb

In the above output image, 1 record means the database contains 1 key-value pair.
Setting Hash Table Size for Backup
To set the hash table size of the backup database, use the -n option. For example, to set the hash table size in the backup to 8192, use the tdbbackup command in the following way −
tdbbackup -n 8192 share_info.tdb
In the above command, 8192 means 8192 slots in the hash table.
Open with Read-Only Locking
To open the tdb file with read-only locking, use the -r option −
tdbbackup -r share_info.tdb
Skipping Locking during Backup
Locking ensures that multiple processes do not access or modify the same data simultaneously, preventing potential corruption. The -l option skips locking during backup −
tdbbackup -l share_info.tdb
Only use this for tdb files that do not support locking or are lock-free.
Displaying Usage Help
To display the usage help, use the -h option with the tdbbackup command −
tdbbackup -h
Conclusion
The tdbbackup command in Linux is used to back up and verify the integrity of .tdb files, which store important Samba data such as session info and configurations. It offers several options for customizing backups, including setting suffixes, checking for corruption, adjusting hash sizes, and managing file locking.
In this tutorial, we covered the tdbbackup command, its installation, syntax, options, and usage in Linux with examples.