Jump to content

Backup Batch File


Recommended Posts

I have two servers, I need to dump the drives from one onto the other. I'm putting together a batch file to do this. It needs to dump to a folder named for each day of the week. If someone with a good understanding of batching could take a quick glance over this and let me know what they think, I'd appreciate it. Be nice because I am relatively new to the batch file game.

@echo off

REM Delete drives if in use:

net use x: /delete /yes

net use y: /delete /yes

net use z: /delete /yes

REM Map drives from the server:

net use x: \\s1\c$ /yes

net use y: \\s1\d$ /yes

net use z: \\s1\e$ /yes

REM Insert backup statement

@echo off

::variables

set drive=e:\backups\s1

set folder=%date:~0,3%

set backupcmd=xcopy /s /c /e /h /i /r /k /y

%backupcmd% "x:" "%drive%\c\%folder%"

%backupcmd% "y:" "%drive%\d\%folder%"

%backupcmd% "z:" "%drive%\e\%folder%"

REM End backup statement

REM Delete drives again..

net use x: /delete /yes

net use y: /delete /yes

net use z: /delete /yes

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...