twooly
Mar 31 2004, 07:42 PM
Just thought I would share this
Here is what I did. I only use the MSDE engine to run my Helm control panel. So I only backup the one db. I did a full restore on my test server using a backup and had the server online in about 4 hours even counting the software install (give you have that part documented)
Features:
-My Zip File has the date of the backup
-Does a backup of all MySQL databases
-Does a backup of the Helm DB
-Backup of your php.ini
-Does a backup of Mailenable settings and users email boxes.
-Purges Bad Mail and items in users deleted items (Mailenable)
-Does a backup of all user files
-Does a backup of Microsoft DNS zones
-Does a backup of the IIS meabase
-Creates one zip file
-Sends the zip file to a remote location through FTP
-Emails you when complete
There are several files to do all this but you just schedule the one command file. Make sure that the bin dir for mysql, winzip is in your path and mailenable is in your path. The only add on you will need is the command line for winzip
Enjoy and hope this helps out some people
---------------------------------------------------------------------------
Main command file
---------------------------------------------------------------------------
for /F "tokens=1-4 delims=/ " %%I IN ('date /t') DO set DT=%%J%%K%%L
mkdir c:backups%DT%_Sites
mysqldump --all-databases > c:backups%DT%all_%DT%.sql
C:backupsosql.exe -S{localhost} -Usa -P{sapassword} -dmaster -ic:backupsbackup.sql -r1 -m-1
copy c:winntphp.ini c:backups%DT%
cd Program FilesMail EnableBin
MEPurge.exe 1 BADMAIL> mailclean.log
MEPurge.exe 1 POSTMASTER>> mailclean.log
MEPurge.exe 5 DELETED>> mailclean.log
move mailclean.log c:backups%DT%
mebackup /BACKUP
wzzip -r -P c:backups%DT%_sitesall_sites_%DT%.zip C:Sites*.*
wzzip -r -P c:backups%DT%_sitesdns_%DT%.zip C:WINNTsystem32dnsbackup*.*
wzzip -r -P c:backups%DT%iis_%DT%.zip "C:WINNTsystem32inetsrvmetabase.xml
wzzip -r -P c:backups%DT%_sitesall_backup_%DT%.zip c:backups%DT%_sites*.*
copy c:backups%DT%_sitesall_backup_%DT%.zip c:backups
cd
cd c:backups
ECHO open ftp.yourserver.com> ftpdaily.txt
ECHO username>> ftpdaily.txt
ECHO password>> ftpdaily.txt
ECHO put all_daily_%DT%.zip>> ftpdaily.txt
ECHO quit>> ftpdaily.txt
ftp -s:ftpdaily.txt
delete all_backup_%DT%.zip
call email.vbs
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
email.vbs
--------------------------------------------------------------------------------
Set WSHNetwork = CreateObject("WScript.Network")
computerName = WSHNetwork.ComputerName
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "you@yourdomain.com"
objEmail.To = "you@yourdomain.com"
objEmail.Subject = computerName & " Daily Backup status"
objEmail.Textbody = computerName & " is complete is the daily backup. Please check the zip file."
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
"localhost"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
---------------------------------------------------------------------------------
---------------------------------------------------------------------------------
backup.sql
---------------------------------------------------------------------------------
USE master
GO
BACKUP DATABASE HelmDB
TO DISK = 'C:backupshelmhelmdb.bak'
WITH FORMAT,
INIT,
NAME = 'Full Backup of HELMDB';
GO
----------------------------------------------------------------------------------
Vinnie Pasetta
Apr 1 2004, 10:20 AM
Nice job. Since the command line version og WinZip costs money and knowing everyone is cheap, I suggest 7zip -
http://www.7-zip.org/ - which is free and can do the same thing.
Mark Priest
Mar 16 2005, 11:43 AM
Hi There,
This looks like a great script, im new to using windows as a server, Can someone tell me where i install this script and how do i schedule it to run daily at x time.
twooly
Mar 16 2005, 02:58 PM
Open notepad and copy the script into there. Edit lines specific to your setup. Save the file anywhere like c:adminscripts and name it backup.cmd or whatever. Then create a scheduled task to run the script.
Mark Priest
Mar 16 2005, 07:33 PM
Hi Twooly,
Can you just verify the ftp section here for me please.
ECHO open ftp.server> ftpdaily.txt
ECHO username>> ftpdaily.txt
ECHO password>> ftpdaily.txt
ECHO put all_daily_%DT%.zip>> ftpdaily.txt
ECHO quit>> ftpdaily.txt
ftp -s:ftpdaily.txt
what goes where? and what FTP software did you use.
Thanks in advance for your help.
twooly
Mar 16 2005, 07:37 PM
Just change the values in red to your environment.
ECHO open ftp.yourserver.com > ftpdaily.txt
ECHO username>> ftpdaily.txt
ECHO password>> ftpdaily.txt
FTP just have an ftp server setup where you are sending the file and that user can put files there.
Mark Priest
Mar 16 2005, 07:41 PM
OK, will give that a go.
What is the ftpdaily.txt?
Thanks for the super fast replies
twooly
Mar 16 2005, 07:46 PM
ftpdaily is the text file that is getting passed to the command line ftp for what it is supposed to do.
C:Documents and Settingstwooly>ftp --help
Transfers files to and from a computer running an FTP server service
(sometimes called a daemon). Ftp can be used interactively.
FTP [-v] [-d] [-i] [-n] [-g] [-s:filename] [-a] [-w:windowsize] [-A] [host]
-v Suppresses display of remote server responses.
-n Suppresses auto-login upon initial connection.
-i Turns off interactive prompting during multiple file
transfers.
-d Enables debugging.
-g Disables filename globbing (see GLOB command).
-s:filename Specifies a text file containing FTP commands; the
commands will automatically run after FTP starts.
-a Use any local interface when binding data connection.
-A login as anonymous.
-w:buffersize Overrides the default transfer buffer size of 4096.
host Specifies the host name or IP address of the remote
host to connect to.
Notes:
- mget and mput commands take y/n/q for yes/no/quit.
- Use Control-C to abort commands.
Mark Priest
Mar 16 2005, 07:50 PM
OK, i ran the script and it creates the directory but there is nothing in it.
mysqldump --all-databases > c:backups%DT%all_%DT%.sql
doesnt seem like there is enough info here? Is there a way to debug the script?
twooly
Mar 16 2005, 07:52 PM
Can you run mysqldump in your command prompt. Debug, just go line by line manually in a command prompt
Mark Priest
Mar 16 2005, 08:01 PM
Hi,
Its located in the following folder
C:Program FilesMySQLMySQL Server 4.1bin
If i type mysqldump at the command line it states it doesnt recognise the command.....
twooly
Mar 16 2005, 08:13 PM
That means it isn't in your path statement. Add that path to your path variable in your system control panel
Mark Priest
Mar 16 2005, 08:18 PM
Wooo, slow down LOL.
Im not using HELM, this is just a standard windows web server edition,
I presume what you mentioned was a part of HELM? Please correct me if im wrong
twooly
Mar 16 2005, 08:20 PM
Nope has nothing to do with helm. The only piece that does is the MSDE db but if you are using MSDE for stuff other than helm it can be applied too.
Mark Priest
Mar 16 2005, 08:25 PM
Ahh HA!
Found it.
Nice little tutorial here.
http://www.wilsonmar.com/1envvars.htm
Mark Priest
Mar 17 2005, 12:52 PM
Hi again,
OK, I now have my backup working thanks to you, however, I did notice there seems to be some descrepancies in your script. some of the directories are incomplete and it means that the zips etc dont get written.
I hope you don't mind, but I am going to post a full tutorial on what I have done using your script as a basis?
Mark Priest
Mar 30 2005, 02:03 PM
Hi Again,
Still playing with your script! One thing I didnt realize is that it doesnt send the email at the end of the script. if i double click the email.vbs file it sends it fine, but it doesnt call it. Is there a reason for this that you know of?
Also, with the time function, is there a way to get it to look at the day -2 The reason i ask is becuase it would be nice to get the script to delete the backups after x days.
Look forward to your reply.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.