Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Zeticloud Services

Pages: [1]
1
Backup / Automatically Backup Emails to Remote Server
« on: September 26, 2019, 06:28:53 PM »
I have the problem to make regular backups for users emails. The problem is that the admin module "Backup" DOES NOT INCLUDE EMAILS, only public_html dir and mysql DB. The same is with "remote backup": no emails are backed up, the only way to accomplish a mail backup using CWP options is under User Panel > File Management > Backup > Full Account Backup, but I didn't find a way to make this automatic. So, I implemented this solution:


Prerequisites

I'm assuming you have the REMOTE BACKUP option enabled and working, since this solution uses "ssh -i" authentication method (same as "remote backup").


Incremental Backup for Emails to Remote Server

I created in local server a file in "/" dir called "mailBackup.sh" with this code:

rsync -av -e 'ssh -p 2200 -i /root/.ssh/backup/id_rsa' /var/vmail backup@xxx.xxx.xxx.xxx:/home/backup/cwp_remote/email/server6

As you may notice, I'm connecting to the remote server's IP (obfuscated here) via SSH using a user I already setup there called "backup" (must be able to connect via SSH, so check user's permissions in CWP). As I already mention, SSH KEY must be setup properly in remote backup option (locally and remote) for this to work.

The backup is made using incremental "rsync" command, where I'm coping everything under local server "/var/vmail" dir to remote server dir "/home/backup/cwp_remote/email/server6", this, because I have several servers, all making backups to the same Backup Server but to it's own directory.

Finally, in order to make this backups automatic, I just added a "root cron job" in CWP panel as follows:

35 01 * * sun /bin/bash /mailBackup.sh

Here, I'm programming the email backup to be executed every Sunday at 01:35 hrs.

I hope this helps! :)

Pages: [1]