Computing.Net > Forums > Networking > backup batch file help

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

backup batch file help

Reply to Message Icon

Name: bowtie1
Date: July 17, 2007 at 12:21:41 Pacific
OS: WinServer 2003
CPU/Ram: ?
Product: Dell
Comment:

I've read numerous posts and found a couple of websites on creating batch files but I still dont feel comfortable making one yet.

I have 2 servers in my network. I need to backup a certain folder (and all its contents) from one server to the other. I would like for it to do this M-F nightly at 9pm(I believe I would do this part through task scheduler though). I would like for it to overwrite itself each time also.

The folder I am wanting to backup is located:

\\Server2\F:\sun\backup

The destination folder I would like this folder to go to is:

\\server1\D:\SCbackup

The purpose for me doing this is because I dont have remote backup for my Veritas software to backup server2. I just want to copy that folder from server2 to server1 before the nightly backup occurs on server1 through Veritas.

Also, if anyone knows of a good website that could teach batch files to a beginner I would appreciate a link.

Thanks,

Joe




Sponsored Link
Ads by Google

Response Number 1
Name: jefro
Date: July 17, 2007 at 14:28:35 Pacific
Reply:

Not sure I'd use a batch file but many people do.


Start here maybe.
http://www.microsoft.com/windowsxp/...

I read it wrong and answer it wrong too. So get off my case you goober.


0

Response Number 2
Name: Curt R
Date: July 17, 2007 at 14:47:35 Pacific
Reply:

Here's a batchfile I use at home, and have used for clients under similar circumstances to your own.

First, you have to create the backup set in ntbackup. Then schedule it. Open the scheduled backup to copy the command line from it to use in the backup batchfile.

***begin batchfile***

@echo off

rem clear mapped network drive to destination (backup) folder

net use w: /d /y

rem map network drive to backup folder on server

net use w: \\server\username /persistent:yes

rem perform the backup

C:\WINDOWS\system32\ntbackup.exe backup "@C:\Documents and Settings\username\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data\Daily Backup.bks" /n "Daily Backup.bkf created 6/6/2005 at 11:04 AM" /d "Set created 6/6/2005 at 11:04 AM" /v:yes /r:no /rs:no /hc:off /m normal /j "Daily Backup" /l:s /f "C:\Backup\Daily Backup.bkf"

rem copy the backup to the server

xcopy c:\backup\"daily backup.bkf" w:\ /y

rem release mapped drive

net use w: /d /y

rem exit the batch file

exit

***end batchfile***

You would change the line mapping the drive to reflect your shared (destination) folder:
\\server1\D:\SCbackup

Note: You shouldn't need drive letters in your mapping as you shouldn't have more than one shared folder of the same name on the same server, regardless of number of available drives. This is to avoid confusion. So the mapping should look as follows:
\\server\SCbackup

One thing to note, in my batchfile I have it release the mapped drive first, then map it and release it again at the end of the batchfile. I've found windows tends to behave erratically at times with mapped drives and found this the best way to ensure a consistent drive mapping.


You will also have to tweak the path in the xcopy command to reflect the location of your backed up file.


0

Response Number 3
Name: bowtie1
Date: July 18, 2007 at 06:01:57 Pacific
Reply:

Thank you very much Curt. This is going to help me a lot. The only thing I may need to change is the actual backup you are performing. The files I am copying from the f:sun\backup are the actual backup files themself. The program that uses this DB already performs the backup and puts it in this location. All I need to do is simply copy that backup folder over to the other server.

But I will be able to pick through your batch file and find what I need. Thanks.

I do have one more question you may be able to help me with. Is there a way to copy a folder and all its contents but omit a certain file or folder within that folder? I think I saw the code somewhere but dont remember where.

Thanks,

Joe


0

Response Number 4
Name: Curt R
Date: July 18, 2007 at 12:06:03 Pacific
Reply:

All I need to do is simply copy that backup folder over to the other server.

Even easier then. If the DB backup is a single file, you'll want to ook into that folder, find out the file name, remove the "perform backup" section from the batchfile (leaving only the drive mapping and xcopy parts) and put the correct path/filename in the "xcopy" portion.

If it turns out to be multiple files within that folder I highly recommend archiving it using winzip (or winrar or something like that) first, then copying the .zip file over.

Don't forget to test it to verify it's working properly prior to scheduling it.

Hmmm........I don't know about skipping particular files or folders. I'm quite sure it can be done but I'm not that good of a batchfiler. My suggestion is you message "Mechanix2go" here at computing.net and ask him. He's a first class batchfiler and if anyone can help you out, he can.


0

Response Number 5
Name: bowtie1
Date: July 18, 2007 at 20:10:36 Pacific
Reply:

Thank you very much Curt. It works like a charm!


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Networking Forum Home


Sponsored links

Ads by Google


Results for: backup batch file help

Batch file help www.computing.net/answers/networking/batch-file-help/29969.html

Batch File to Configure DNS Suffix www.computing.net/answers/networking/batch-file-to-configure-dns-suffix/25243.html

IP Printing batch file www.computing.net/answers/networking/ip-printing-batch-file/26696.html