Question Locked

Batch Files for Backup

0 helpful
10 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I'm trying to write a simple batch file that takes data from my computer and backs it up on a server. I would like it to include subfolders as well.

COPY "C:\Documents and Settings\kfrost\My Documents\Documentation" "P:\Backups\kfrost"/S

I put this is notepad, saved it as a .bat and it doesn't work. If I get rid of the /S it works fine but doesn't copy any of my subfolders. I have XP pro on my desktop.
Any advice

10 replies

by kfrost

I just had to add some "'s and it worked great. Thanks a lot!!

by dumphrey

command does not use the /S switch. Use the xcopy command, it should be in XP by default, and just change "copy c:\..." to "xcopy c:\..." and use the /S command.
You can also add a ren command and some variable parsing to append the current date to the files.

add
SET usedate2=%DATE:~4,2%%DATE:~7,2%%DATE:~10,4%
to the top of you bat file.
And make the ren command looke like
ren c:\testDir\File1.txt *-%usedate%.txt
this will rename all files to their existing name, but append a date fomat in the MMDDYYYY format.

by kfrost

Does xcopy work with XP pro service pack 1?

by kfrost

I'm trying to use my newly created XCOPY batch to start when the computer is booting up. I'm using the Call command in the Autoexec.bat. When I check to see if files were backed up they arent'. I tried running the autoexec to see what is happening and it's asking "do you want to overwrite the following files. Yes/No/All Is there an extension I can put on my original XCOPY batch to automatically always have it to overwrite the file?

by kfrost

I see. I was using the /-Y. Thanks for the help.

by Member 25348569

Most of the inbuilt commands such as DEL and COPY and the standalone executables such as XCOPY will list out their switches if you use /?.

Get hold of a copy of ROBOCOPY. It's a Microsoft product that is much better than XCOPY and has advantages such as directory mirroring which is very useful when backing up folders as it removes files from the destination if you remove them from the source folder between backups. ROBOCOPY also supports the copying of security information and the ability to log what it's doing to a file amongst a whole bunch of other stuff.

You'll get it with the windows 2003 reskit: http://www.microsoft.com/Downloads/details.aspx?FamilyID=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en

Some other good stuff in there too that will work with XP although most of it is pretty useless but all free.

Neil :)

This discussion is closed to new replies.