View Full Version : Simple backup solution
dFunk
2003-08-07, 13:49 PM
Anyone have a simple solution for automated backups? On a regular basis I want to automatically backup my wwwroot folder, database folder, metabase.xml, and a few other files. I'd like to be able to zip them then ftp the zip(s) to an offsite server.
Nestor
2003-08-07, 14:10 PM
All of this can be done with batch scripts and the Windows "Scheduled tasks" without any additional software but you're going to have to get creative.
Use the Back utility that comes with Windows, save the session and make it save to a compressed file instead of device. Schedule a task run the back up regularly. Write an FTP script as (i.e. ftp.bat) schedule a task for the FTP script and walla...
dFunk
2003-08-07, 15:54 PM
Thanks Nestor. That's a good idea. I've never done any ftp'ing through a batch file, but I can probably figure it out.
dFunk
2003-08-08, 08:51 AM
This is interesting. I used the backup utility on the wwwroot folder and the compressed size was 126Mb. Using zip (actually Send To --> Compressed Folder) it was only 55Mb. I also like the zip file better because it's easier to get into, look around, extract one file, etc. So is there a way to zip a folder from a batch file or script?
Nestor
2003-08-08, 12:13 PM
Are you using winzip?
Nestor
2003-08-08, 12:24 PM
Originally posted by dFunk
Thanks Nestor. That's a good idea. I've never done any ftp'ing through a batch file, but I can probably figure it out. The FTP batch file is easy. You have to create a script maybe call it script.txt and put your FTP commands in it. Make sure you save and run from the directory where your back up file is located. Example:
open ftp.myserver.com
user me
pass 5555
cd /remote-ftp/dir
put thisfile.zip thisfile.zip
quit
The batch file ftp.bat would look like this
ftp -s:script.txt
Now go to the scedualed tasks and schedual ftp.bat to run at a certain time. Make sure to run from the back up dir. Oh, try to run this under the 'service' account. I think if you run as administrator, you have to leave the session open for it to run but that's not always the case. Play with it and report back.
Hope this helps :)
wunderlin
2003-08-08, 16:44 PM
Nestor, nice tip- thanks! :)
dFunk
2003-08-08, 16:45 PM
Well alright! I actually got this to work! :D
I found a freeware program called ldzip (http://ldzip.port5.com) that runs from the command line. I put the command to run it in a batch file along with the ftp line, and configured my ftpscript.txt. The scheduled task runs using my account even when I'm not logged in (wasn't sure how to use the 'service' account).
Now, one more thing: In IIS 6.0 all I need to restore websites after rebuilding the server is a) the web folders and b) metabase.xml. It can't be that easy, can it?
laxbobber
2003-08-12, 01:07 AM
http://www.ncftp.com/ has some nice scriptable tools.
ncftpget / ncftpput work great...
I have a batch file zip up things into a directory for "outgoing backups" then I download them every night to a different server with ncftpget which downloads and removes them from the source server.
TWooly
2003-08-14, 21:36 PM
How exactly can you backup the IIS 6 config from the command line? Also does anyone know how to backup an MSDE database from the command line?
Thanks
--Todd
bdee1
2003-09-03, 20:24 PM
i am in the process of setting up a similar backup routine on my web server and was wondering exactly what you are backign up on your servers.... i know i have to do the web folders but how do i backup the data from IIS on w2k and the data from mailenable?
any help would be greatly appreciated
bdee1
2003-09-03, 20:42 PM
oh and also how do i backup cold fusion settings and DSNs
laxbobber
2003-09-03, 21:06 PM
Right now I'm backing up files that users change, access databases, sql db backups and mailenable. For everything but mailenable I just zip it up and ftp it. For mailenable refer to this entry:
http://www.mailenable.com/kb/viewarticle.asp?aid=24
bdee1
2003-09-03, 22:25 PM
how do you determine which files users have changed?
laxbobber
2003-09-03, 23:09 PM
At this point I'm not worrying about it...
I just zip it ALL up every night for now!
alemos
2003-09-04, 12:12 PM
another suggestion is to use SecondCopy to compress everything. It's quite easy and customizable. You setup profiles and you can even tell it to only add files that have changed. You can configure it to create filename20030903.zip files with the date changing everyday and then all you need is an FTP script to send it all over (the batch script worked fine for me using *.zip to send all zip files over). Then I just delete the zips I have ftp'd and pronto.
On my local computer, I burn a CD a day with all the backups from the previous day and I have a collection now. Oh, I'm using CD-RWs to save :D
kbrown
2003-09-05, 12:36 PM
Originally posted by dFunk
Well alright! I actually got this to work! :D
I found a freeware program called ldzip (http://ldzip.port5.com) that runs from the command line. I put the command to run it in a batch file along with the ftp line, and configured my ftpscript.txt. The scheduled task runs using my account even when I'm not logged in (wasn't sure how to use the 'service' account).
Now, one more thing: In IIS 6.0 all I need to restore websites after rebuilding the server is a) the web folders and b) metabase.xml. It can't be that easy, can it?
My understanding is that everything about any given site in IIS 6 is in the metabase.xml file. You can actually copy it to other servers and duplicate your setup on multiple machines from this one file.
bdee1
2003-09-05, 12:47 PM
where can i find the metabase.xml file and how woudl i go about restoring it on another machine?
Originally posted by kbrown
My understanding is that everything about any given site in IIS 6 is in the metabase.xml file. You can actually copy it to other servers and duplicate your setup on multiple machines from this one file.
What about IIS 5?
Nestor
2003-09-05, 20:30 PM
Originally posted by bdee1
where can i find the metabase.xml file and how woudl i go about restoring it on another machine? Off the top of my head this is what I remember since I haven't do this in a while :o , my bad.. On your MMC console for IIS 6.0, right click the "Websites" folder and choose "Back-up/Restore Configuration" option. Choose location where to save the metabase back-up file.
To restore, do the same only this time do it in reverse.
alemos
2003-09-05, 21:47 PM
Nestor, for IIS 5 the backup/restore procedure only works if it's on the same installation of Windows on the same machine. If you have to reinstall windows, the backup won't work.
There are a number of IIS backup utilities on the net. I am going to try a few and let you guys know what I got.
bdee1
2003-10-01, 13:41 PM
any word on those IIS backup utilities?
dFunk
2003-10-02, 11:07 AM
I've gotten this working pretty smoothly, so I thought I'd summarize what I have done. This process automatically backs up all MSDE databases, all web sites (actually the wwwroot folder), the IIS metabase, and a couple other misc. folders, then FTPs the zip offsite. Best thing about it is it's free!
Step 1: Automatically backup all MSDE databases. I do this by running a stored procedure from the command line. The stored procedure is below. You can put it in any database as long as the user account you use for the Scheduled Task has access to that db. My database backups are going to a folder named 'c:\db_backups\' so you may need to modify this to suit your needs.
CREATE PROCEDURE [dbo].[proc_backupAllDBs] AS
SET QUOTED_IDENTIFIER off
select getdate() "Start Time"
set nocount on
declare @dbname varchar(36),@cmd varchar(255)
declare dbname_cursor cursor
for select name from master..sysdatabases where name != 'tempdb'
order by name
open dbname_cursor
fetch dbname_cursor into @dbname
while @@fetch_status = 0
begin
if DATABASEPROPERTYEX(@dbname,'Status') = 'ONLINE'
begin
select @cmd ='backup database '+@dbname+' to DISK="c:\db_backups\'+@dbname+'.bak" with init'
print @cmd
execute (@cmd)
end
fetch dbname_cursor into @dbname
end
close dbname_cursor
deallocate dbname_cursor
select getdate() "End Time"
Step 2: Copy desired files/folders to a Zip file. This is done with a command line utility called LDzip (http://ldzip.port5.com). This program will have you create a text file called include.ld in which you list everything to zip up. My flie is something like this:
c:\inetpub\wwwroot\*.* /s
c:\db_backups\*.* /s
c:\winnt\system32\inetsrv\metabase.xml
I put the ldzip files and all other files for my backups (in next steps) in a folder called 'c:/backup'.
Step 3: Create an FTP script. This script will be run from a batch file. Mine is called ftpscript.txt, and is something like this:
open myftpsite.com
myuid
mypassword
cd backups
put c:\wwwrtbak.zip wwwrtbak.zip
quit
The syntax for FTP scripts varies a little with server software, but something along these lines should do it.
Step 4: Create a batch file to run the above scripts and stored procedure. I called it wwwbackup.bat:
osql -Dmaster -Q"proc_backupAllDBs" -E
ldzip.exe c:\wwwrtbak -m2000 -o -i -n -q
ftp -s:ftpscript.txt
The first line runs the stored procedure from the Master database. The -E switch tells it to use the current login, which is the one you specify to use in the Scheduled Task.
The second line runs ldzip and creates a file called wwwroot.zip with all the stuff in it. See the ldzip documentation for more details and options. You can break up the zip into multiple files if you are backing up a lot of data.
The third line starts an FTP session using the script from step 3.
Step 5: Create a scheduled task to run the batch file. Open the Task Manager and use the wizard to create a task that runs the batch file. I have mine set to run daily at 3:00 AM.
As I said, you will need to modify these scripts to match your setup.
Hope you find this useful. It works for me!
-Drew
Valdar
2004-03-31, 20:18 PM
This is an excellent post on how to automate your backups.
I did what you did, but with a slight twist. I have a server at home that is on VPN with my serverbeach server so rather than ftp I just move the file over to a mapped drive and then I have automated tape backups on my server at home.
The only thing I wish I could do is to automatically put the date on the zip file somehow. But your solutions works perfectly! Thank you for posting it!
TWooly
2004-03-31, 21:01 PM
Here is what I did. I only use the MSDE engine to run my Helm control panel. So I only backup the one db. But I have a few more things I do.
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:\backups\osql.exe -S{localhost} -Usa -P{sapassword} -dmaster -ic:\backups\backup.sql -r1 -m-1
copy c:\winnt\php.ini c:\backups\%DT%\
cd Program Files\Mail Enable\Bin
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%_sites\all_sites_%DT%.zip C:\Sites\*.*
wzzip -r -P c:\backups\%DT%_sites\dns_%DT%.zip C:\WINNT\system32\dns\backup\*.*
wzzip -r -P c:\backups\%DT%\iis_%DT%.zip "C:\WINNT\system32\inetsrv\metabase.xml
wzzip -r -P c:\backups\%DT%_sites\all_backup_%DT%.zip c:\backups\%DT%_sites\*.*
copy c:\backups\%DT%_sites\all_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:\backups\helm\helmdb.bak'
WITH FORMAT,
INIT,
NAME = 'Full Backup of HELMDB';
GO
----------------------------------------------------------------------------------
Easyeieio
2004-04-02, 03:59 AM
Brilliant, many thanks, those two posts were just what I was looking for. Now have a nice and simple backup plan set up on my servers (-; Cheers!
Wired
2004-04-03, 12:31 PM
Great info in this thread!
May I suggest that it get posted in the FAQ section? I am sure a lot of people would benefit from it
devilspgd
2004-04-10, 05:03 AM
I've been using a program called UNISON to synchronize the data with another server (or even your own desktop) -- From there, I backup to CD.
The advantage of unison is that it uses the rsync protocol, it can handle small changes to huge files with relatively little bandwidth, and it's been extremely reliable in my own testing.
karmaahost
2004-05-03, 14:45 PM
Has anyone used Arcserve to backup the entire server with all the agents installed for all the files? We are in process of purchasing the Arcserve version 11 which has different agents to do the backups and just wanted to know the review of this.
We just want to backup everything on our server to our home PC which is hooked with bunch of external firewire drives with larger capacity.
Any suggestions, comments or concerns please share.
Thanks
Karmaahost
vBulletin® v3.6.8, Copyright ©2000-2009, Jelsoft Enterprises Ltd.