try creating a VBS file, like bkup.vbs and include the following:
Code:
function copyfile(xfile, yfile)
Set fso = CreateObject("Scripting.FileSystemObject")
fso.CopyFile xfile, yfile,TRUE
set fso = Nothing
end function
then call it to copy the files in the main() part of your code
Alternately, do it as a CMD script:
Code:
src=%1
bkdir=c:\Program Files\database\BACKUPS
copy %src% %bkdir%
exit
I prefer to do server side scripting in BASH/GNU hybrid scripts. You have to do a lot of messing around to set variable names from STDOUT redirected output in CMD.
Something you may want to consider is how to do logging of your backups, often log files have the date information in the name.
Here is (a rather poor) example of a hybrid script to manuplate a date string, ultimately formatting it to be a DOS env variable"
Code:
date /t | cut -d' ' -f2 | cut -c 1,2,4,5,7,8,9,10 > %TMP%\x
FOR /F %%v IN (%TMP%\x) DO set DATELOG=%%v
date /t | sed -e 's/ /_/g' > %TMP%\x
time /t | sed -e 's/ /_/g' > %TMP%\y
FOR /F %%v IN (%TMP%\x) DO set x=%%v
FOR /F %%v IN (%TMP%\y) DO set y=%%v
set DATETIME=%x% %y%
date/for/set are CMD commands.
cut/sed are GNU commands
the FOR loops read the content of the temporary files and intantiate a variable in the DOS env.
one code then use the above DATETIME variable to construct a date based filename:
Code:
set LOG=%bkdir%\%DATETIME%.log
When you do your database file copy, you can use redirection in DOS to accomplish log entries:
Code:
echo DATABASE COPY %src% at time %DATETIME% >> %LOG%
Finally, you may want to do an MD5 checksum of the original and the copy, and also write that to the log:
Code:
echo CHECKSUM %src% >> %LOG%
md5sum %src% >> %LOG%
echo CHECKSUM BACKUP %src% >> %LOG%
md5sum %bkdir%\%src% >> %LOG%
that way you are more assured that you got a good copy of the file.
You could automate the validation:
Code:
md5sum %src% > %TMP%\x
md5sum %bkdir%\%src% > %TMP%\y
FOR /F %%v IN (%TMP%\x) DO set SRCCKSUM=%%v
FOR /F %%v IN (%TMP%\y) DO set BKCKSUM=%%v
if NOT %x%==%y% then GOTO ERROR01
...
:ERROR01
set ERRMSG="A BACKUP ERROR HAS OCCURED - CHECKSUM INVALID ON BACKUP"
goto MAILADMIN
...
upon which you use a mail client (like ChilKat) to send an email to the Admin that the backup failed.
Hope this helps.
John Lopez
Enterprise PDM Architect
john.l.lopez@goodrich.com