Zedan IT Blog

IT definitions, discussions and more

Daily backup script for MDaemon (or other servers)

Here I will present a simple backup script for MDaemon mail server on windows 2003 in a simple, fast and efficient way.

The good thing about MDaemon server that you can simple backup the configuration & mail folders and then replace it on a freshly installed server and you get the same mail server you have before, so why not making a script to back these folders automatically.

Please note that to use this script you must configure MDaemon to start as a windows service.

Below is a simple batch file containing commands to stop the MDaemon, backup files & folders then start MDaemon again.   In this batch file I use the NTbackup solution, but ofcource you can replace this with a simple xcopy batch file.   I always prefer NTbackup for compression and verification.

Suppose you have a disk E: that you will take backup on,  the following script will create a folder for backup every day.

Create a folder in C:\ and name it C:\scripts , then Open notepad and place the following commands and save them as backup.bat

D:\MDaemon\app\MDLaunch.exe /stop

E:
cd\
md “%date%”
cd “%date%”

echo Mail Server Windows Backup Started at: %date%_%time% >>BackupLog.txt

C:\Windows\system32\NTBACKUP.EXE backup “@C:\scripts\WinBackup.bks” /n “MAILBACKUP” /d “MAILBACKUP %date% %time%” /v:yes /r:no /rs:no /hc:off /m normal /j “Mail Server Daily Backup” /l:s /f “E:\%date%\MAILBACKUP.bkf”

echo Mail server Windows Backup Completed at:  %date%_%time% >>BackupLog.txt

D:\MDaemon\app\MDLaunch.exe

 This will create new folder and rename it by today’s date and place the backup  “MAILBACKUP.bkf”  inside it.  Remember to create the BKS file for the NTbackup program (e.g. winbackup.bks) in the scripts folder  which will include the MDaemon folders.   For more information refer to my post on windows 2003 backup.

The first command is stop the MDaemon service and the last command is to start the MDaemon service again.

I use the echo commands to create a log file of the backup.

I hope this gave you an idea on automating backup secripts, and you can use it in other servers, for example sql server by stopping the service, copy the database files then starting the sql service again.

If you like this article the please leave a comment and if you would like to share with an article or a tip please send it to  ” mohamed@mzedan.com “

2 responses to “Daily backup script for MDaemon (or other servers)

  1. Sam Strachan 25/05/2013 at 2:17 AM

    I prefer xcopy. Restoring is just copying back the folder. Using NTBackup only complicates things. I found xcopy faster and less worrysome…
    Here is what I use. I dump to an external drive and also zip and ftp over to backup site. I then restore for a 24 hour mirror.
    ________________________________________________________
    S:
    cd\
    md mail_backup\%date%
    cd mail_backup\%date%

    echo Mail Server Windows Backup Started at: %date%_%time% >>BackupLog.txt

    C:\MDaemon\app\MDLaunch.exe /stop
    copy C:\MDAEMON\APP /E /G /I /H /K /Y /C
    C:\MDaemon\app\MDLaunch.exe

    copy C:\MDAEMON /E /G /I /H /K /Y /C

    echo Mail server Windows Backup Completed at: %date%_%time% >>BackupLog.txt

    So this will create a folder with today’s date; stop MDaemon; copy the APP folder; start MDaemon; copy the other folders (suppressing any ‘file in use’ messages) and Voila. By only stopping MDaemon to get the App folder I reduced my down time to 8 seconds. This is less than a DNS lookup.

    Also while we’re at it, Let’s do some housekeeping…
    You have to fix the Windows date format to remove the slashes. Go into Control Panel and select Regional and Language Options. Click Customize on the Regional tab. Selecte the Date tab. Change the Date Separator to a dash. Change the short date to yyyy-MM-dd while you are in here.

    This makes for a cleaner folder structure; ready to zip and ftp to your off-site…

    Cheers!!

  2. nikhil 13/02/2015 at 11:46 AM

    Very very nice…

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s