file copy macro

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
jnbell

file copy macro

Post by jnbell » Thu Aug 26, 2004 12:52 pm

Hi...

I'm new to Marco Scheduler and I want to copy certain files between networked computers at night.

We do not have a domain just a work group in WINXP SP2.

I hope someone can give me a sample script to copy files from 3 different computers to our main office computer and have it run everynight at about midnight. The files to be copied will be the same files everynight.

If you can please email me at [email protected]

Thanks a bunch!

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Thu Aug 26, 2004 8:07 pm

I just grabbed this from an library of past work. May have some errors in here, but should give you an idea on how to approach this. This is based on using registerer version of XXCOPY to do the copying. You can use copy or xcopy or xcopy32 with different switches. Actually copies files from multiple workstations to two different "central" backup drives.
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
//Developed by Bob Hansen, Sensible Solutions Inc. 2/10/2004.
//[email protected], 603-898-8223, Salem, NH.
//Developed for ******************* INC.
//Purpose: Backup Local Hard Drives to Single Hard Drive.
//==========================================================
//Development notes for future:
//Use Message> vs. MessageModal> in order to run unattended.
//==========================================================
Label>UserVariables
//User Defined variables, customize for individual machines

//Enter the SourcesDestinations for the Computers to be copied from. Use UNC vs. Drive Letters.
//Set MaxCount=Drives to copy: F, G, H, I, J, L
Let>MaxCount=6

//Drive F:
Let>Source1=\\MAIN\C\*.*
Let>Destination1=\\OFFICE1\C\BACKUPS\F
Let>Exclude1=/XBACKUPS\

//Drive G:
Let>Source2=\\OFFICE1\C\*.*
Let>Destination2=\\MAIN\C\BACKUPS\G /X BACKUPS
Let>Exclude2=/XBACKUPS\

//Drive H:
Let>Source3=\\OFFICE2\C\*.*
Let>Destination3=\\MAIN\C\BACKUPS\H
Let>Exclude3=

//Drive I:
Let>Source4=\\OFFICE3\C\*.*
Let>Destination4=\\MAIN\C\BACKUPS\I
Let>Exclude4=

//Drive L:
Let>Source5=\\OFFICE1\D\*.*
Let>Destination5=\\MAIN\C\BACKUPS\L
Let>Exclude5=

//Drive J:
Let>Source6=\\OFFICE4\C\*.*
Let>Destination6=\\MAIN\C\BACKUPS\J
Let>Exclude6=

//Next line is original for testing
Let>Source6=\\OFFICE1\D\*.*
Let>Destination6=\\MAIN\C\BACKUPS\L
Let>Exclude6=

Label>MacroVariables
//Macro Defined variables, not to be changed by user.
CAPSOFF
Let>SK_DELAY=10
Let>CF_OVERWRITE=1
Let>MSG_STAYONTOP=1
Let>RP_WAIT=1
Let>Count=0
Year>YYYY
Month>MM
Day>DD
//===================================================

Label>Start
Message>Starting Backup Routines

Label>DailyDrive
DayofWeek>Weekday
//Weekdays are Sun-Sat, 1-7
Remark> the next line to do backups on Sunday
If>%Weekday%=1,End
Remark> the next line to do backups on Saturday
If>%Weekday%=7,End

Label>CopyFile
Label>Continue
Let>Count=Count+1
Let Source=Source%Count%
Let Destination=Destination%Count%
Let Exclude=Exclude%Count%
GetTime>Time
Message>Starting Backup of files%CRLF%from %Source% to %Destination%%CRLF%at %Time%
TimeStamp>G:Data\Logs\Backups\%YYYY%%MM%%DD%_Server.log, Starting Backup of %Source% to %Destination%

//Check for Source and Destination?
//Copy message above >>G:\Data\Logs\Backups\%YYYY%%MM%%DD%_Server.log

// /BACKUP = Standard Backup without deleting any file (/CLONE without /ZY).
// A shortcut for the following combination: /KS/H/E/R/Q/Y/BI/ZE/oD0.
// /X filedir\ = Directory to be excluded from source
Run Program>command.com /c xxcopy %Source% %Destination% %Exclude% /backup /PB >>G:\Data\Logs\Backups\%YYYY%%MM%%DD%_Server.log
Wait>10
//WaitWindowClosed>XXCOPY*

GetTime>Time
TimeStamp>G:Data\Logs\Backups\%YYYY%%MM%%DD%_Server.log, Ending Backup of %Source% to %Destination%
Message>Backup of files%CRLF%from %Source% to %Destination%%CRLF%completed at %Time%.
If>%Count%End

Label>ErrorSource
Message>Source files not found.
Wait>5
Goto>End

Label>MissingDrive
Message>Drive %Drive% not found.
Wait>5
Goto>End

Label>ErrorDestination
Message>Destination location not found.
Wait>5

Label>End
TimeStamp>G:Data\Logs\Backups\%YYYY%%MM%%DD%_Server.log, ========== End of backups on %MM%-%DD%-%YYYY% ==========
Message>Backup Process Completed.
//Wait>5
//Macro>J:\DATA\MJTMacroScheduler\CPU\TestConnections.scp
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
//Insert a Call Macro to send 3 emails with backup results
NOTE: Have not reviewed this in 6 months. Probably was fine tuned when on actual client site. I seem to recall that UNC paths were needed vs. Mapped Drives. I think that Mapped drives did not work for some reason, probably a limitation with xxcopy vs. Macro Scheduler. This was WIN98SE workstations, peer-to-peer Windows network. (You will need to change Run Program> command.com to cmd for XP). Also had routine to email backup results of backups to Office Manager with CCs including me.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts