I need to know how to backup and restore my Atmail installation.
- On-Premise Server + WebMail Installations: Version 7.0 > Current Version
- Webmail Only Installations: Version 7.0 > Current Version
- Best practice requirements back up and restore
Backups are an important part of maintaining your Atmail system. This guide lists the many possible ways you can backup your Atmail server - offsite, or otherwise.
Backup to a local directory (Full backups)
This script can be used to backup your Atmail installation, and store it to a local drive or directory.
This script can be automated using cron, and executes as either the root user, or as the 'atmail' user:
# Atmail directory
# Backup destination
# Date tag for backup files
# Dump each database to its own file
mysqldump --opt -u mysql-user --password=
# Copy the atmail startup scripts to their own database (optional)
# Dump atmail to its own file
Backup to local directory (Incremental)
This script can be used to perform incremental backups of your Atmail system, using rsync. This is local-local only, and has to be within disks of the same filesystem format. This has the benefit of using significantly less space on large-scale deployments. Installation of rsync is required.
Backup to external server (FTP)
The following script creates backup files and moves/transfers them using FTP, without need for intermediate files. This makes sure that you can use as much of your allotted disk space as necessary. Without the need for intermediate files, you will not need to make sure that your local system has enough space for a full tar file. This method comes with the benefit of being able to make use of as much disk space as you can.
Backup to external storage (SSH)
This method creates a tar file directly on the destination storage server, using the SSH protocol. This method provides an additional layer of security when transferring data over the network, and is recommended for external servers encompassing the public internet. As per above, this method does not require intermediate files. This makes sure that you can use as much of your allotted disk space as necessary. Without the need for intermediate files, you will not need to make sure that your local system has enough space for a full tar file. This method comes with the benefit of being able to make use of as much disk space as you can.
Servers crash - and when they do, it's always nice to know that you can always restore from backups. This portion of the document details how to recover your data and restore your installation to optimal state.
This document details various ways to recover your MySQL data. For the sake of simplification, the following flagged words refer to different server settings:
[dbname] - database name
[dbuser] - database user
Recover MySQL database from dump file
If your backup utility created a MySQL dump file, all you need to do is reimport it. First, create a backup of your current database:
If this dump fails because of database corruption, you might want to create a backup of your MySQL data directory instead:
After the backups are done, drop the database under the MySQL terminal:
For example, a drop command for a database called 'sample_data' would look like this:
Create the database again:
You can then import your old data with this command:
Where 'mysqldump.sql' is your backed-up MySQL dump file.
Recover MySQL data from binlogs.
If your server has binlogs enabled, you can export the full history of MySQL commands for your server. This can then be imported into MySQL, so you can have a query-by-query replica of the MySQL server state you wish to restore.
For the purposes of this document, we are going to assume that your MySQL bin log directory is '/var/log/mysql/'. The directory then contains these files:
First, identify the timeframe you wish to restore. By default, specifying no flags outputs every query executed during the duration of the binlogs (default: 10 days).
In some cases, you may want to just specify a slice of time to restore the data from. If this is the case, you will need to specify the following flags:
The datetime format follows YYYY-MM-DD HH:MM:SS. For this document, we will use the following parameters:
- Start time: 2012-02-14 22:13:01
- Stop time: 2012-05-14 00:00:00
The MySQL binlog command is as follows:
This will generate a file called 'mysql-binlog-queries.sql'. You can then import this file:
Mail Restoration (Single User)
In the event of a need to restore a single user's account, you are to do the following:
- Login to WebAdmin > User Manager, and recreate the user
- Execute the following:
Where [FIRST] is the first letter of the account, [SECOND] is the second letter, and [ACCOUNT NAME] is the email address. For example, a user called firstname.lastname@example.org will need the following command:
Then, go into the frontend servers (appliances), and execute:
Where the format is:
Mail Restoration (Global)
In the even of a filesystem catastrophic failure that prevents access to the maildir files, you are torestore the MailDir via the following steps:
- Create the base directory:
- Unpack Atmail: