Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

backup batch file help

Original Message
Name: bowtie1
Date: July 17, 2007 at 12:21:41 Pacific
Subject: backup batch file help
OS: WinServer 2003
CPU/Ram: ?
Model/Manufacturer: 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



Report Offensive Message For Removal


Response Number 1
Name: jefro
Date: July 17, 2007 at 14:28:35 Pacific
Subject: backup batch file help
Reply: (edit)
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.


Report Offensive Follow Up For Removal

Response Number 2
Name: Curt R
Date: July 17, 2007 at 14:47:35 Pacific
Subject: backup batch file help
Reply: (edit)
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.


Report Offensive Follow Up For Removal

Response Number 3
Name: bowtie1
Date: July 18, 2007 at 06:01:57 Pacific
Subject: backup batch file help
Reply: (edit)
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


Report Offensive Follow Up For Removal

Response Number 4
Name: Curt R
Date: July 18, 2007 at 12:06:03 Pacific
Subject: backup batch file help
Reply: (edit)
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.


Report Offensive Follow Up For Removal

Response Number 5
Name: bowtie1
Date: July 18, 2007 at 20:10:36 Pacific
Subject: backup batch file help
Reply: (edit)
Thank you very much Curt. It works like a charm!

Report Offensive Follow Up For Removal




Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: backup batch file help

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




XP Installed to G?

exessive internet traffic

ZoneAlarm Question. Blocked Connect

Windows Live Messenger Problem

Delete $Uninstall after SP3 updates


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC