XCOPY & BACKUP

W

Wilmar Perez

I am looking for a simple solution to automatically backup
the users's files and folders. The idea is to copy only
the office format (.doc, .xls, .ppt, .mdb) documents they
create to a shared folder in a file server on the network.

I've been thinking about using xcopy in a batch file that
runs when the user logs off from her workstation. So,
this is my batch file:

REM Copy documents from the user work station to the file
server called babel REM I use the first two lines just to
register the time and date date /T >>
\\babel\UserDocs$\xcopy.log time /T >>
\\babel\UserDocs$\xcopy.log

REM The following is a single line
xcopy "c:\Documents and Settings\%username%\Mis
documentos\*.*" \\babel\UserDocs$\% username%
\ /c /s /r /i /o /x /k /e /z /exclude:\\babel\UserDocs$\ex
clude.txt >> \\babel\UserDocs$\xcopy.log

REM And here it ends

My exlude.txt file is:

..mp3
..wav
..exe
..com
..src


So, what I want to ask is if you see anything wrong in the
way I'm handling the problem. Also I would like to know
if there is any way in which I could tell xcopy to copy
just a certain kind of files rathar than to exclude an
endless lot of them.

Thanks a lot for your help.
 
P

Pegasus \(MVP\)

Wilmar Perez said:
I am looking for a simple solution to automatically backup
the users's files and folders. The idea is to copy only
the office format (.doc, .xls, .ppt, .mdb) documents they
create to a shared folder in a file server on the network.

I've been thinking about using xcopy in a batch file that
runs when the user logs off from her workstation. So,
this is my batch file:

REM Copy documents from the user work station to the file
server called babel REM I use the first two lines just to
register the time and date date /T >>
\\babel\UserDocs$\xcopy.log time /T >>
\\babel\UserDocs$\xcopy.log

REM The following is a single line
xcopy "c:\Documents and Settings\%username%\Mis
documentos\*.*" \\babel\UserDocs$\% username%
\ /c /s /r /i /o /x /k /e /z /exclude:\\babel\UserDocs$\ex
clude.txt >> \\babel\UserDocs$\xcopy.log

REM And here it ends

My exlude.txt file is:

.mp3
.wav
.exe
.com
.src


So, what I want to ask is if you see anything wrong in the
way I'm handling the problem. Also I would like to know
if there is any way in which I could tell xcopy to copy
just a certain kind of files rathar than to exclude an
endless lot of them.

Thanks a lot for your help.

You could use this type of syntax:

@echo off
for %%a in (doc xls ppt mdb) do xcopy /s /y /c c:\*.%%a d:\Target\

In your zoo of switches, you omitted the /y switch. It's an extremely
important switch - it's absence may cause your batch file to hang
while waiting for your response.
 
P

Pegasus \(MVP\)

Major Malfunction said:
Your script looks similar to one I created to do a quick and dirty server
backup. My other suggestion is instead of an exclude file, why not specify
what you do want? As in:

xcopy "c:\Documents and Settings\%username%\Misdocumentos\*.doc"
\\babel\UserDocs$\% username% /y

and simplify by going to just a "y" switch to automatically replace existing
files? Yes it would require the line be repeated for each extension, but I
think it would give more control as to what your *are* backing up.

Don't forget the /c switch! Without it, many of your files might
never get backed up at all!

<snip>
 
D

David Turner

Pegasus (MVP) wrote
Don't forget the /c switch! Without it, many of your files might
never get backed up at all!

I use /r/i/c/h/k/e/y/s

Easy for me to remember.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top