15.3 Data recovery from back-up
Prev | Chapter 15 Email archiving and backup | Next

## 15.3 Data recovery from back-up

A special tool called Kerio MailServer Recover is used for recovery of the backup data. The tool extracts the back-up and saves the data in their original location in the Kerio MailServer hierarchy.

To launch Kerio MailServer Recover, run the `kmsrecover` command from the directory where Kerio MailServer is installed.

Usage:

`kmsrecover [options] <directory_name>|<file_name>`

On Mac OS X and Linux it is necessary to enter a command on the following format, unless having already been introduced in the file of the `path` system variable:

`./kmsrecover [options] <directory_name>|<file_name>`

This means that it is necessary to add the `./` string before the utility name that will inform the system that the command to be used is in the current directory.

You can also see these details and examples to individual attributes, by running the following command.

`kmsrecover -h` or `kmsrecover --help`

### Warning

- Kerio MailServer must be installed on the computer which the `kmsrecover` tool is launched from.

- It is necessary to stop the Kerio MailServer Engine prior to the recovery.

- If Kerio MailServer Recover is run without advanced parameters specified otherwise, all items in the Kerio MailServer's data store, such as configuration files, licenses, mailing lists and data, will be overwritten.

The Kerio MailServer Recover tool allows setting of many advanced options for back-up data recovery, as follows:

Abbreviation | Full option | Mask | Description
--- | --- | --- | ---
`-d` | `--domain` |  | Recovers (or lists with parameter `-l`) all backed-up data for the specified domain..
`-u` | `--user` |  | Recovers (or lists with parameter `-l`) data of the specified user.
`-f` | `--folder` |  | This option recovers the specified folder of the user (this option requires setting of the `-d` and `-u` options).
`-s` | `--store` |  | This option sets where SpamAssassin databases, mailing lists and emails (including events, notes, contacts, etc.) would be unpacked and stored. By default, the `store` on the Kerio MailServer from which `kmsrecover` was launched is used.
`-c` | `--cfgdir` |  | This option sets a directory where configuration files, SSL certificates and licenses would be stored. By default, the current folder from which the `kmsrecover` command was started is used.
`-m` | `--mask` |  | This option allows to set which parts of the back up would be recovered. It requires setting of mask with `-m <value>` or`--mask=<value>`. `<value>` stands for any combination mentioned below. Example: `-m cfg,license,sslca,sslcert` — this command recovers license, SSL certificates and configuration files.
|  | `cfg` | This argument recovers only configuration files mailserver.cfg and users.cfg where server configurations are defined.

Abbreviation | Full option | Mask | Description
--- | --- | --- | ---
|  | `mail` | This recovers only the `\store\mail` directory.
|  | `lists` | This argument recovers only configuration of mailing lists (`\store\lists`).
|  | `spamassassin` | This argument recovers only the SpamAssassin database.
|  | `license` | This argument recovers the Kerio MailServer license.
|  | `sslca` | This argument recovers certificates issued by certification authorities.
|  | `sslcert` | This argument recovers Kerio MailServer's certificates.
|  | `public` | This argument recovers public folders.
`-b` | `--backup` |  | This option performs an additional back-up before the recovery is started. The original directory will have the BAK extension. If such a file already exists, it will be replaced by the new version. However, bear in mind that backup of the current status doubles the store size. It is therefore not desirable to use this option if there is not enough free disk space available.
`-g` | `--noprogress` |  | This option hides information about the recovery progress. It is useful especially if the recovery is recorded in the log. Information of how much time is left to the completion of the recovery process is irrelevant in that case.
`-l` | `--listing` |  | This option lists the backup store content. It is also possible to us additional parameters (such as `-d` and `-u` which lists only contents of the mailbox of the specific user).
`-q` | `--quiet` |  | Recovery progress information will not be provided in the command line.
`-v` | `--verbose` |  | Recovery progress information will be provided in the command line.
`-h` | `--help` |  | This option prints out the help file.

Backup recovery will be better understood through these simple examples:

### Examples for Windows

Full backup recovery

  The directory with configuration data is stored at the default location (as set as default during the installation), the `store` directory is located on a separate disk (RAID or a faster disk) of the same computer where the configuration directory, and the backup directory is located on an exchangeable disk. For backup recovery, use full backup.

  Conditions:

  1. The configuration data is stored under

     `C:\Program Files\Kerio\MailServer`

  2. The store directory is located in

     `D:\store`

  3. For security purposes, the backup directory is stored on the removable disk

     `E:\backup`

  Solution:

  The command must be run from the directory where Kerio MailServer is installed. In this case, the directory is

  `C:\Program Files\Kerio\MailServer`

  At this point, two command formats can be used:

  1. We want to recover the last complete backup (the most recent full and differential backups or the most recent backup copy). The command will be as follows:

     `kmsrecover E:\backup`

  2. To recover a particular backup (except the last one), use the following format:

     `kmsrecover E:\backup\F20051009T220008Z.zip`

  The `kmsrecover` detects the path to the store (`D:\store`) automatically in the Kerio MailServer's configuration file and uses it.

  ### Warning

  If the parameter contains a space in a directory name, it must be closed in quotes. For example:

  `kmsrecover "E:\backup 2"`

Recovery of a single user's mailbox

  - The directory with the backup is stored on an external disk E,

  - we need to get a single user's mailbox from the backup,

  - the entire mailbox and its content will be saved out of the Kerio MailServer's store (folder `\tmp`).

  `kmsrecover -d company.com -u smith`

  `-s D:\tmp E:\backup\F20051009T220008Z.zip`

Recovery of a single folder of a user

  - The directory with the backup is stored on an external disk E,

  - one specific folder of the user mailbox must be gained from the backup (`Sent Items` in this case),

  - the command is run in the verbose mode (parameter `-v`) which allows to monitor the recovery process.

  `kmsrecover -v -d company.com -u smith -f "Sent Items" E:\backup\F20051009T220008Z.zip`

Recovery of public folders of a particular domain

  - The directory with the backup is stored on an external disk E,

  - it is now necessary to recover the domain's public folders (the `public` mask will be used here),

  - and the original public folders will be kept at the same time (status before using Kerio MailServer Recover). This will be done simply by using the `-b` parameter.

  `kmsrecover -b -d company.com -m public E:\backup`

### Examples for Mac OS X

Full backup recovery

  The directory with configuration data is stored at the default location (as set as default during the installation), the `store` directory is located on a separate disk of the same computer where the configuration directory, and the backup directory is located on an exchangeable disk. For backup recovery, use the most recent full backup.

  Conditions:

  1. The configuration data is stored under

     `/usr/local/kerio/mailserver`

  2. The store directory is located in

     `/store`

  3. For security purposes, the backup directory is stored on the removable disk

     `/Volume/backup`

  Solution:

  The command must be run from the directory where Kerio MailServer is installed. Therefore, it is necessary to go to the directory:

  `/usr/local/kerio/mailserver`

  We want to recover the last complete backup (the most recent full and differential backups or the most recent backup copy). Now, the command pattern depends on the fact whether the path to the Kerio MailServer directory is included in the path variable or not. If the path is not set there, the command will be as follows:

  `./kmsrecover /Volume/backup`

  Otherwise, it will be like this:

  `kmsrecover /Volume/backup`

  The `kmsrecover` detects the path to the store (`/store`) automatically in the Kerio MailServer's configuration file and uses it.

Recovery of a single user's mailbox

  - The directory with the backup is stored on an external disk,

  - we need to get a single user's mailbox from the backup,

  - the entire mailbox and its content will be saved out of the Kerio MailServer's store (folder `/Temp`).

  `./kmsrecover -d company.com -u wsmith -s /Volume/Temp /Volume/backup/F20051009T220008Z.zip`

Recovery of a single folder of a user

  - The directory with the backup is stored on an external disk,

  - one specific folder of the user mailbox must be gained from the backup (`Sent Items` in this case),

  - the command is run in the verbose mode (parameter `-v`) which allows to monitor the recovery process.

  `./kmsrecover -v -d company.com -u wsmith -f "Sent Items" /Volume/backup/F20051009T220008Z.zip`

Recovery of public folders of a particular domain

  - The directory with the backup is stored on an external disk,

  - it is now necessary to recover the domain's public folders (the `public` mask will be used here),

  - and the original public folders will be kept at the same time (status before using Kerio MailServer Recover). This will be done simply by using the `-b` parameter.

  `./kmsrecover -b -d company.com -m public /Volume/backup`

### The backup structure

Each archive consists of backup type and date when it was created:

- Full backup — `F20060118T220007Z.zip`

  F — full backup

  2006 — year

  01 — month

  18 — day

  T220007Z — GMT timestamp (22:00:07);it always starts with T and ends with Z.

- Differencial backup — `I20060106T220006Z.zip`

  I — differential backup

  2006 — year

  01 — month

  06 — day

  T220006Z — GMT timestamp (22:00:06);it always starts with T and ends with Z.

- Backup copy (manual back up startup) — `C20060117T084217Z.zip`

  2006 — year

  01 — month

  17 — day

  T084217Z — GMT timestamp (08:42:17);it always starts with T and ends with Z.

Each backup includes the following files and directories:

- `.version.txt` — the file is created at the start of the backup creation process and it includes the following information:

  - `started` — date of the start of the backup creation in pattern `YYYY-MM-DD hh:mm:ss`.

  - `version` — version of the backup tool.

  - `hostname` — DNS name of the Kerio MailServer host which the backup was created for.

- `@backup` — the main directory of the backup. This directory includes the following items.

  - `license` — license backup

  - `sslca` — backup of certification authorities' certificates.

  - `sslcert` — backup of Kerio MailServer's SSL certificates.

  - `store` — backup of the data store

- `mailserver.cfg` — a file with the Kerio MailServer configuration. All settings done in the administration interface are saved in `mailserver.cfg`.

- `users.cfg` — a file with user configuration. It involves all users and their parameters set in the Kerio MailServer's administration interface.

- `.summary.txt` — the file is created at the end of the backup creation process and it includes the following information:

  - `started` — date of the start of the backup creation in pattern `YYYY-MM-DD hh:mm:ss`.

  - `finished` — date of the backup completion in pattern `YYYY-MM-DD hh:mm:ss`.

  - `count_files` — number of backed-up files.

  - `total_size` — total size of the files (in bytes) which are backed-up in the interval between creation of files `.version.txt` and `.summary.txt`.

  - `duration` — total time of the backup creation process in pattern `hh:mm:ss:msms`

Prev | Up | Next
15.2 Back-up of user mailboxes and basic server configuration | Contents | Chapter 16 Server's Certificates