S 6.135 Regular backup of important system components of a Samba server

Initiation responsibility: Head of IT, IT Security Officer

Implementation responsibility: Person responsible for the data backup

The failure of a Samba server may have a serious effect on the business processes of a government agency or a company. Unintentional changes, for example misconfigurations or hardware errors, may make it necessary to recover important system components. The important system components only include the actual system files (such as the smbd daemon of the Samba package, for example), but also configuration data (such as the data in smb.conf), status information (in the trivial database (TDB) files, for example), and logged data (such as the log file of the smbd daemon). The data backup must be performed in accordance with the specifications of the data backup policy (see module S 1.4 Data backup policy).

When restoring configuration data, status information, and system files, it should be ensured that they are compatible with each other. For example, if configuration data is used to restore the configuration of a Samba server that was originally used with a newer version of the Samba package, this may lead to problems. It is possible that the older version of Samba does not evaluate some of the parameters in the configuration, because they were introduced for the first time in a later version of Samba. This may lead to undesired (side) effects or may even completely impede the operation of Samba. In addition, it should be ensured before restoration that the basic operating system is set up exactly as it was before (see also S 4.331 Secure configuration of the operating system of a Samba server).

Based on the availability requirements and the role as a server, the restoration itself and the time it takes for restoration should be tested and improved regularly within the framework of a business continuity plan for the server.

In order to be able to restore a Samba server to a previous state, the following data / information should be backed up regularly:

The following sections contain safeguards for backing up this data / information.

The smb.conf file (configuration data)

The smb.conf file is the main configuration file of Samba. The settings specified in this file control the response of the Samba services (nmbd, smbd, and winbindd).

Where this file is actually stored depends on the options with which Samba was compiled. The storage location of the file can be displayed using the command "smbd -b | grep smb.conf".

TDB files (configuration data and status information)

Samba stores a variety of information in the TDB files. Here are some examples:

Samba stores TDB files in two different directories. Using "smbd - b | grep PRIVATE_DIR", it is possible to determine the location of the PRIVATE_DIR directory except when the "private dir" option is used in the smb.conf file. The TDB files containing confidential information are stored in this folder. The second directory used is the LOCKDIR directory. This directory is used to store TDB files containing information that is not confidential. The storage location of the LOCKDIR directory can be output using "smbd -b | grep LOCKDIR", unless the "lock directory" option is used in smb.conf.

It is recommended to create backup copies of all TDB files in both directories regularly. TDB files stored in the subdirectories of these two directories do not need to be backed up. These files do not contain any information needed for restoration. It must be ensured that the TDB files are backed up properly (see the section "Correct backup of TDB files").

Account information (status information)

Depending on which backend ("passdb backend" parameter in smb.conf) Samba uses to store the account information, it may be necessary to select a different method for the backup. Several backends can be used simultaneously in Samba 3.0.0 to Samba 3.0.23. Earlier versions as well as later versions of Samba do not support this function.

For restoration purposes, it is necessary to regularly back up the account information from all backends used. The following approaches are recommended for backing up the account information depending on which backend or which backends are used:

The directory containing the log files (logged data)

The nmbd, smbd, and winbindd daemons store their log files in this directory. This data is not needed to restore a Samba server to a previous state. However, this data should be backed up regularly nevertheless so that it is possible to track down the causes of errors.

Unless configured differently in smb.conf ("log file" option), the location of the directory depends on which options were used to compile Samba. In this case, the directory can be determined by entering the command "smbd -b | grep LOGFILEBASE".

Correct backup of TDB files

The TDB is a database in a binary database format similar to the Berkeley DB format that supports concurrent write accesses from several processes, as well as locking. One particularity of the TDB files is that the content of the databases is often stored temporarily by the daemons (nmbd, smbd, and winbindd) for longer periods of time and the content on the hard disk must not necessarily always be up to date at runtime. Furthermore, the time stamps of the TDB files are not updated when data is written to these files.

If TDB files are backed up during live operation using unsuitable programs (for example "cp"), such programs will not take these particularities into consideration. The backups created in this case may be useless under some circumstances. Backup mechanisms such as "rsync" have problems during normal operation due to the fact that the time stamps of the TDB files do not change after write operations. Rsync is not able to detect whether or not the content of the TDB files has changed since the last backup, for example.

In order to create consistent backups of the databases while Samba is running, the "tdbbackup" application must be used. The command "tdbbackup /etc/samba/passdb.tdb" creates the backup file /etc/samba/ passdb.tdb.bak. The command "tdbbackup -v etc/samba/passdb.tdb" can be used to check the integrity of the database. If corrupt data is found, a backup file (if one exists) is used to restore the database. When called with the parameter's, tdbbackup can determine which file name extensions should be used for the backup and the integrity check. Instead of ".bak", a date specification such as ".20080303" may also be used.

Review questions: