1

Topic: Backup Mailboxes Using backup_mysql.sh

==== Required information ====
- iRedMail version (check /etc/iredmail-release): 0.9.7
- Linux/BSD distribution name and version: CentOS 7
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL
- Web server (Apache or Nginx):Apache
- Manage mail accounts with iRedAdmin-Pro? Yes
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====

Is there a way to have the automated backup script backup_mysql.sh also tar and copy the mailbox folder (/var/vmail/ I think) to the same location and at the same time everyday?  Or is there another backup script that does that?  I didn't realize that I haven't been backing up my user's email since I installed iRedMail. 

I realize I could create my own cron job to tar and copy the folder to my network backup location, but I would like to integrate it into the one that is automatically setup with iRedMail and seems to work quite well.  Then all the backups would be in the same location and it would delete the old ones automatically.

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: Backup Mailboxes Using backup_mysql.sh

Backup mailboxes on same server everyday? Your disk space will be used too much and become full soon if you have many large mailboxes.

You can use tools like 'rsync' to backup mailboxes to another local directory or a remote server, it will be better in this case.

3

Re: Backup Mailboxes Using backup_mysql.sh

You make a valid point.  rsync is a nice way to do that.  I decided to use tar in order to keep multiple copies of the backup in case one gets corrupted, deleted, infected, etc.  I wrote a script as such for reference and for others to use and stored it in /var/vmail/backup/backup_mailboxes.sh.  It deletes any files older than 10 days in the target directory:

cd /var
mount path/to/our/SAN /mnt
tar -zcvf vmail-backup${TIMESTAMP}.tar.gz /var/vmail/
mv /var/vmail/vmail-backup${TIMESTAMP}.tar.gz /mnt/SAN/mailboxes
find /mnt/SAN/mailboxes/ -mindepth 1 -mtime +10 -delete
echo "Mailbox backup script was run.  Please check SAN/mailboxes/ directory to see that the latest 10 days of mailboxes are there." | mail -s "iRedMail Mailbox Backup Script Was Run" it@mycompany.com

Then I added it to the daily cron job using:

# crontab -e -u root
0   4   *   *   *   bash /path/to/backup_mysql.sh

If you can see any issues with that, please let me know, but it seems to work on my system.