tdbrestore
Restore Samba TDB database files
SYNOPSIS
tdbrestore [options] <tdb_file>
Example usage: tdbdump /path/to/original.tdb | tdbrestore /path/to/new.tdb
PARAMETERS
-h, --help
Display a brief help message and exit.
-v, --verbose
Enable verbose output, showing more details about the restoration process.
-a, --append
Append the dumped data to an existing TDB file. If this option is not used, tdbrestore will overwrite the target tdb_file if it already exists, potentially leading to data loss.
<tdb_file>
The path to the TDB file where the data will be restored. This file will be created if it doesn't exist, or overwritten/appended to based on the -a option.
DESCRIPTION
The tdbrestore command is a utility provided by the Samba suite, designed to restore Trivial Database (TDB) files from a previously created dump. TDB files are lightweight, key-value databases crucial for Samba's internal operations, storing information like user accounts, group mappings, share configurations, and lock states.
tdbrestore reads the TDB dump, typically generated by the tdbdump command, from standard input and reconstructs the TDB file specified as an argument. This command is indispensable for disaster recovery, allowing administrators to restore corrupted TDB files, or for migrating TDB data between Samba installations. It's vital to ensure that Samba services are stopped before restoring critical TDBs to prevent data corruption or inconsistency.
CAVEATS
Overwriting Data: By default, tdbrestore will overwrite the target TDB file if it already exists. Use the -a (append) option to add data to an existing file instead.
Prerequisites: The command relies on a TDB dump created by tdbdump. Without a valid dump file, tdbrestore cannot reconstruct the database.
Service Interruption: For critical Samba TDBs (e.g., passdb.tdb, secrets.tdb), it is highly recommended to stop all related Samba services (like smbd, nmbd, winbindd) before performing a restore operation to prevent data corruption or inconsistencies caused by concurrent access.
COMMON TDB FILES IN SAMBA
Many critical Samba functions rely on TDB files. Examples include passdb.tdb (stores user password hashes and account information), secrets.tdb (stores sensitive cryptographic keys), group_mapping.tdb (maps Windows SIDs to Unix GIDs), and share_info.tdb (stores share definitions). Understanding which TDB file to restore is crucial for effective recovery.
USAGE EXAMPLE FOR BACKUP AND RESTORE
1. Backup a TDB file:
tdbdump /var/lib/samba/private/passdb.tdb > /path/to/backup/passdb.tdb.dump
2. Restore the TDB file (after stopping Samba services):
cat /path/to/backup/passdb.tdb.dump | tdbrestore /var/lib/samba/private/passdb.tdb
HISTORY
tdbrestore is an integral utility of the Samba project, an open-source software suite that provides file and print services to SMB/CIFS clients. Samba's development began in the early 1990s, and TDB (Trivial Database) was introduced as a lightweight, persistent key-value store to manage various internal data structures, replacing earlier ad-hoc file formats. tdbrestore, alongside tdbdump, was developed to provide essential backup and recovery capabilities for these critical TDB files, ensuring the robustness and manageability of Samba deployments.