Backing Up hMailserver & MySQL

Use this forum if you have installed hMailServer and want to ask a question related to a production release of hMailServer. Before posting, please read the troubleshooting guide. A large part of all reported issues are already described in detail here.
Post Reply
drakakistours
Normal user
Normal user
Posts: 49
Joined: 2017-10-22 08:23

Backing Up hMailserver & MySQL

Post by drakakistours » 2017-10-31 12:55

G'day All

I have scoured google and the forums and have created a backup process that I wanted to share and check that I hadn't missed anything:

Step 1: vbscript to pause hMailServer using the com api, then start the batch file
Step 2: batch file to stop the hMailServer & mysql processes and copy the following items to a backup directory on the server using robocopy:

MySQL Data folder
hMailServer.ini
hMailServer Events Folder
hMailServer Data Folder
hMailServer Logs Folder

Step 3: restart hmailserver & mysql processes and call vbscript to resume hMailServer
Step 4: Zip the backup directory and send to our offsite NAS

That's it! If anyone can see anything I have missed, or anything I have done wrong, would appreciate feedback. I am still really new to emails & SQL

Cheers :D

User avatar
jimimaseye
Moderator
Moderator
Posts: 8584
Joined: 2011-09-08 17:48

Re: Backing Up hMailserver & MySQL

Post by jimimaseye » 2017-10-31 13:52

You copying the MySQL data folder or doing a MySQL DUMP?
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

drakakistours
Normal user
Normal user
Posts: 49
Joined: 2017-10-22 08:23

Re: Backing Up hMailserver & MySQL

Post by drakakistours » 2017-10-31 14:06

jimimaseye wrote:You copying the MySQL data folder or doing a MySQL DUMP?
Copying the folder. So doing a physical backup but flushing the tables before I stop the MySQL service

User avatar
jimimaseye
Moderator
Moderator
Posts: 8584
Joined: 2011-09-08 17:48

Re: Backing Up hMailserver & MySQL

Post by jimimaseye » 2017-10-31 15:15

My only thoughts are its not really necessary to PAUSE hmailserver as you are then going to do a 'stop service'.

Also, I personally do a dump so that the 'backup file' is small (and further zipable) and more importantly the restore of the MySQL database is completely independant of the destination MySQL setup (in case you are restoring to a new machine). Buyt if you are comfortable with the configuratio of MySQL and that simply copying back in the mysql data directory from backup wont cause an issue (even if you install MySQL on a new machine/install path) then so be it as long as it works for you.

(FYI: My method is here: viewtopic.php?f=21&t=28139 so you can see what I mean. Your procedure is quite similar.)
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

drakakistours
Normal user
Normal user
Posts: 49
Joined: 2017-10-22 08:23

Re: Backing Up hMailserver & MySQL

Post by drakakistours » 2017-10-31 15:34

jimimaseye wrote:My only thoughts are its not really necessary to PAUSE hmailserver as you are then going to do a 'stop service'.

Also, I personally do a dump so that the 'backup file' is small (and further zipable) and more importantly the restore of the MySQL database is completely independant of the destination MySQL setup (in case you are restoring to a new machine). Buyt if you are comfortable with the configuratio of MySQL and that simply copying back in the mysql data directory from backup wont cause an issue (even if you install MySQL on a new machine/install path) then so be it as long as it works for you.

(FYI: My method is here: viewtopic.php?f=21&t=28139 so you can see what I mean. Your procedure is quite similar.)
Thanks for thw feedback.

I didn't come across your post in my search, so I will check through it later.

The reason I pause hmailserver is because I read that the pause will bring it nicely to a stop whereas just stopping the process could cause issues. Let me know if that's wrong but I'd rather be safe than sorry.

I am using an external SQL database, so I don't know if that changes things. I read on the MySQL site that a physical copy is quicker to restore and more flexible than a dump, unless I misunderstood. Space isn't really an issue, and our total mail files are less than 10GB total at the moment and are due an archive.

User avatar
jimimaseye
Moderator
Moderator
Posts: 8584
Joined: 2011-09-08 17:48

Re: Backing Up hMailserver & MySQL

Post by jimimaseye » 2017-10-31 16:50

I am using an external SQL database, so I don't know if that changes things.
Nope
I read on the MySQL site that a physical copy is quicker to restore and more flexible than a dump,
This is a similar size to our setup (out mail is 11.5GB with some 35,400 emali files) and I can tell you that the robocopy and mysql dump between service down and service up is about 35 seconds of which most of that is robocopy.

This was last nights log (summarised). You can see that somewhere between starting the MYSQLDUMP and starting the next action it is less than 2 seconds.
20:00:01.39 stopping HMS service

20:00:02.94 robocopy started
<<----- mail files copied here
20:00:32 robocopy finished

20:00:33 performing SA updates

<< ---- SA update ocurred
<<<----- MYSQLDUMP HERE

20:00:35 restarting SA service
20:00:37.88 starting HMS service
Mysql dump took about 1 second if that (SA download and update plus the MSQLDUMP is all less than 2 seconds). And I can tell you from previous 'restores' that it takes about 2 seconds to restore from too.
The reason I pause hmailserver is because I read that the pause will bring it nicely to a stop whereas just stopping the process could cause issues
Previous versions maybe but the latest version has been fixed to shutdown the service correctly. However, pausing before stopping wont hurt either way.
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

drakakistours
Normal user
Normal user
Posts: 49
Joined: 2017-10-22 08:23

Re: Backing Up hMailserver & MySQL

Post by drakakistours » 2017-11-01 08:52

Thanks for your help, and your post (not sure why it didn't come up.)

I have abandoned a lot of my code in favor of yours, it's a lot more robust!

User avatar
jimimaseye
Moderator
Moderator
Posts: 8584
Joined: 2011-09-08 17:48

Re: Backing Up hMailserver & MySQL

Post by jimimaseye » 2017-11-01 10:10

drakakistours wrote:Thanks for your help, and your post (not sure why it didn't come up.)

I have abandoned a lot of my code in favor of yours, it's a lot more robust!
Cheers, thanks for the feedback. (I hope it gives confidence to others).

As for 'searching' : Hmailserver forum SEARCH is a bit cr@p. You will ALWAYS be better putting your search in to google with "hmailserver" at the end. It find a lot more (even from the forums).
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

Post Reply