Batch file in XP Pro SP2 to backup files...

rush24t3

2[H]4U
Joined
Jun 1, 2004
Messages
2,540
I have an external hard drive I used for weekly backups, and once files have been copied, I disconnect it. The only thing is, I have to manually copy and paste the files, some of which haven't been changed, so it takes a while sometimes to copy all the data.

I don't want to use Windows' backup tool, nor do I want to install a third-party app. What I'd like to have is a batch file (or whatever the equivalent is under XP) that will copy ONLY the files that have been created or changed, something I would only have to double-click from a shortcut to start. I have several partitions, so I'd need it to copy the files to specific folders on the external drive one after another.

I have no clue about programming or writing scripts and whatnot, so if any gurus here could lend me a hand with this, I'd be grateful.

Thanks!
 
Steel Chicken said:
xcopy /A

for more info, run cmd
type xcopy /?

Wow, awesome! Thanks a million!!! Even I can figure that one out...

Just one more quesation, though: once I have the line for each partition typed out, how can I make one shortcut that will launch the xcopy?
 
Synchronize it, much better than xcopy as it will only copy update files. Search offline files in help, should have the step-by-steps there. It's also automated...
 
Torquemada XP said:
Wow, awesome! Thanks a million!!! Even I can figure that one out...

Just one more quesation, though: once I have the line for each partition typed out, how can I make one shortcut that will launch the xcopy?

create a text file in notepad on your desktop

type in all your xcopy commands
then save it with a .bat extension

dbl-click
profit!!!!!
 
Steel Chicken said:
create a text file in notepad on your desktop

type in all your xcopy commands
then save it with a .bat extension

dbl-click
profit!!!!!

Wow...want some money? You've earned it! ;)

Thanks again.
 
do you want to post your xcopy batch file here? I am to lazy to make my own, i so figure id just edit yours :p :)

t[H]nx
Torquemada XP said:
Wow...want some money? You've earned it! ;)

Thanks again.
 
chronic9 said:
do you want to post your xcopy batch file here? I am to lazy to make my own, i so figure id just edit yours :p :)

t[H]nx

Share the wealth, eh? :)

I'll post the lines I used, edit as needed:

XCOPY E:\ M:\(E) PERSONAL /S /I /Y /D
XCOPY F:\ M:\(F) MP3 JAZZ /S /I /Y /D
XCOPY G:\ M:\(G) MP3 OTHER /S /I /Y /D
XCOPY H:\ M:\(H) HTML /S /I /Y /D
XCOPY I:\ M:\(I) PICS /S /I /Y /D
XCOPY J:\ M:\(J) VIDEO /S /I /Y /D
XCOPY K:\ M:\(K) PROJECTS /S /I /Y /D
XCOPY L:\ M:\(L) LOOPS /S /I /Y /D
XCOPY M:\ M:\(M) BACKUP /S /I /Y /D

Works like a dream!
 
Here's mine for comparison. I put it in the root directory of the external drive, and I think I can use tweakUI to auto-run it when I turn the drive on -- I've at least added it to the "What do you want to do?" menu.
Code:
@echo off
rem *** This script runs a backup to my external hard drive.
rem *** It should be run from the external drive.
echo Backing up essential data (Press Ctrl-C to abort)
echo Backing up My Documents...
xcopy "%UserProfile%\My Documents" "%UserName%\My Documents" /D /E /C /I /Q /K /Y /EXCLUDE:nocpy.txt
  IF ERRORLEVEL 4 GOTO LOWMEM
  IF ERRORLEVEL 2 GOTO ABORT
echo Backing up Firefox profile...
xcopy "%AppData%\Mozilla" "%UserName%\Firefox" /D /E /C /I /Q /K /Y /EXCLUDE:nocpy.txt
  IF ERRORLEVEL 4 GOTO LOWMEM
  IF ERRORLEVEL 2 GOTO ABORT
echo Backing up Thunderbird profile...
xcopy "%AppData%\Thunderbird" "%UserName%\Thunderbird" /D /E /C /I /Q /K /Y /EXCLUDE:nocpy.txt
  IF ERRORLEVEL 4 GOTO LOWMEM
  IF ERRORLEVEL 2 GOTO ABORT
echo Backing up website development...
xcopy "C:\webroot" "%UserName%\Web" /D /E /C /I /Q /K /Y
  IF ERRORLEVEL 4 GOTO LOWMEM
  IF ERRORLEVEL 2 GOTO ABORT
echo Backing up encryption...
xcopy "C:\GnuPG" "%UserName%\GPG" /D /E /C /I /Q /K /Y
  IF ERRORLEVEL 4 GOTO LOWMEM
  IF ERRORLEVEL 2 GOTO ABORT
  IF ERRORLEVEL 0 GOTO SUCCESS
:LOWMEM
ECHO Insufficient memory to copy files or
ECHO invalid drive or command-line syntax.
GOTO EXIT
:ABORT
ECHO You pressed CTRL+C (^C) to end the copy operation.
GOTO EXIT
:SUCCESS
ECHO Backup completed successfully.
GOTO EXIT
:EXIT
PAUSE
Note: nocpy.txt is a file of exceptions to prevent certain files (like browser caches) from copying, since I don't care about those.
 
Syncronize/off-line files ownes all that BS. ;)

Check it out, I gave up xcopy backups a while ago because of it...

edit: did I mention it has it's built in scheduler with time/date, logon/logoff, and on-idle options? ;)
 
bah, people need to learn the hardway and how its really done, so when they move up to the advanced tools, they can troubleshoot/understand more of whats going on better
 
Phoenix86 said:
edit: did I mention it has it's built in scheduler with time/date, logon/logoff, and on-idle options? ;)
I skipped it figuring that it wouldn't have an on-disk-connect option -- My backup drive gets yanked between backups as electrical protection.

However, if it can be driven by generic events, I'd reevaluate.
 
Steel Chicken said:
bah, people need to learn the hardway and how its really done, so when they move up to the advanced tools, they can troubleshoot/understand more of whats going on better
By advanced do you mean hundreds of people on a network using this as their primary tool to migrate their my documents to a backed up network share? If so, then I agree. They should learn the advanced way. ;)

Yes, I agree knowing the scriptable/command promtp commands is invaluable too.

lomn75 I think that's all the options, time/data (daily/weekly/every X days), logon/logoff, and on idle (and of course on demand, which may work for you). Goto my computer, tools, synch., setup. See if it'll work for you.
 
Phoenix86 said:
By advanced do you mean hundreds of people on a network using this as their primary tool to migrate their my documents to a backed up network share? If so, then I agree. They should learn the advanced way. ;)

Yes, I agree knowing the scriptable/command promtp commands is invaluable too.

lomn75 I think that's all the options, time/data (daily/weekly/every X days), logon/logoff, and on idle (and of course on demand, which may work for you). Goto my computer, tools, synch., setup. See if it'll work for you.

well the average *user* in the business world shouldnot even get to the cmd prompt as far as Im concerned, much less mess around with xcopy *shudder*
 
Steel Chicken said:
well the average *user* in the business world shouldnot even get to the cmd prompt as far as Im concerned, much less mess around with xcopy *shudder*
Dude, you just gave me the heebie jeebies... "user" "xcopy" NO!!!!!!!111!1twenty-eight
 
Hmmm... TweakUI will create an autoplay handler to run the xcopy script for on-connect purposes. Now to see if it'll work with the scheduler (or backup) tool.
 
lomn75 said:
Hmmm... TweakUI will create an autoplay handler to run the xcopy script for on-connect purposes. Now to see if it'll work with the scheduler (or backup) tool.
:cool:

Hmm, I'll have to look at this, would be nice to insert a USB drive and have it "sync" with a folder.

Let me know if you get it working.
 
Phoenix86 said:
Let me know if you get it working.
Not seeing how to get a removeable drive to sync, only stuff over network.

Anyway, from that point, you work in TweakUI under My Computer -> Autoplay -> Handlers

Create a new handler. Change the program to whatever will exec the backup utility (for the xcopy method, this is the batch file) Add arguments as/if needed. Select content type (I use "Mixed Content")

Now jack in your removeable drive. Under My Computer, right-click the drive, Properties, Autoplay tab. For all content types, select "Select an action to perform." If the new handler is for this type, pick it; otherwise, pick "no action."

Now your backup utility should autorun on connect. Pretty handy. For a less-automatic version, create the handler but don't force it to execute -- just pick it out of the list of options.
 
if anyone is not getting enough info from the xcopy help, heres a site thats written where even i understood it:

here
 
Back
Top