Home > Support > WebMail Support Home > How to backup and restore WebMail

How to backup and restore WebMail

You can backup Webmail using @Mail Webadmin > Maintenance > Backup @Mail menu. You can also automate backups by creating a script that runs via the system's crontab each day.

To revert from a backup of the database, you can create a new mySQL database and load the existing mysql database into it.
e.g:

mysql -u root
mysql> create database atmailrevert;
mysql -u root atmailrevert < /tmp/atmaildb.sql

Next, visit the @Mail Webadmin > Config > SQL Configuration and specify the new table name 'atmailrevert'. Here the new database will be used for the application, and local configuraiton files updated to reflect the new database name.

Here is an example script that can be used to backup the database:

#!/bin/bash
# Location to the mySQL database directory 
  M_DIR="/var/lib/mysql/"
# Pathname to the folder to backup data
  B_DIR="/root/mysql-backup/"
# MySQL username
  MYSQL_USER="root"
# MySQL Password
  MYSQL_PASS="n0vember02"
tstamp=`date "+%Y%m%d"`
cd $B_DIR
find $M_DIR/* -type d | while read database; do DB=`basename ${database}`
# Dump each database to its own file
mysqldump -u$MYSQL_USER -u$MYSQL_PASS $DB | gzip > $DB-$tstamp.sql.gz     done
# Last, find any previous backups older then 7 days and remove 
  find $B_DIR     \( -name \*.sql.gz -a -mtime +7 \) -exec rm -f {} \;

Search: