The UCS mail system is based on the mailserver Cyrus. This article describes how to create a full backup of all relevant data concerning the Cyrus mailserver and how to copy the data to a second mail server, e.g. a failover server, or if the mailserver suffered from a hardware defect. For copying the files, the command line tool ''rsync'' is used.

The UCS mail system is based on the mailserver Cyrus. This article describes how to create a full backup of all relevant data concerning the Cyrus mailserver and how to copy the data to a second mail server, e.g. a failover server, or if the mailserver suffered from a hardware defect. For copying the files, the command line tool ''rsync'' is used.

Revision as of 09:26, 5 October 2016

Note: Cool Solutions are articles documenting additional functionality based on Univention products.
Not all of the shown steps in the article are covered by Univention Support. For questions about your support coverage contact your contact person at Univention before you want to implement one of the shown steps.

The UCS mail system is based on the mailserver Cyrus. This article describes how to create a full backup of all relevant data concerning the Cyrus mailserver and how to copy the data to a second mail server, e.g. a failover server, or if the mailserver suffered from a hardware defect. For copying the files, the command line tool rsync is used.

Because the Cyrus mailserver saves its files only in irregular intervals a backup of all files is not possible while the mailserver daemon is running. The described procedure in this article aims for the shortest possible downtime.

This backup will run twice. The first time all noncritical files are copied and in a second run, with a stopped Cyrus mailserver, to copy the latest written data. This article describes how to perfom these steps.

Contents

Preparations

For creating the backup, a separate folder on a device with enough free storage space is required. In this article, the folder /opt/cyrus-backup on the mailserver is used. After the backup is completed, the content can be copied to another server or a removable device.

If a failover mailserver is to be created, a second UCS system must be installed with the mailserver component installed. To ensure the backed-up files are used correctly in the failover server, make sure the same package versions are installed before copying the files to the new server.

All commands in this article are assumed to be run as user root.

First rsync-call

In the first run all Cyrus files, including the mail spool directory, are saved. The folders, that must be copied, can be found in the /etc/imapd/imapd.conf file. The two directories are stored as the variables configdirectory and partition-default:

rsync is also used to save the backup to the failover server. During the copy process, rsync requests the password of the user who copies the files on the remote server. It is adviced to create a SSH key-pair if the backup should run automatically. To copy files to the failover server, rsync must be called twice:

Backup of mailboxes.db

When creating the backup, the file mailboxes.db should be saved separately. This file's content can be recreated by Cyrus, but all information on read mails or marked mails would be lost. If this file is damaged, its content is irrevocably lost. The following command converts the file into a plaintext file:

Reloading this file is only needed, when there is a difference in the Cyrus version between the primary mailserver and the restored server. The file is saved in /var/lib/cyrus and will be saved automatically during the second rsync-call.

To restore the file mailboxes.txt (if needed) at a later time, e.g. after restoring the backup, the following command is used: