Author Topic: Scripting Question: vbscript  (Read 101 times)

Offline SKurj

  • Gold Member
  • *****
  • Posts: 3630
Scripting Question: vbscript
« on: June 28, 2004, 12:36:06 PM »
Ok so coding was by far my worst subject in school this last time around...  

Wish to push a copy  of an sql database backup from one server to the other, but I need to push the right file... this is where I am absolutely lost:

Filename:  ctx_db_200406280516.bak

Now the date and time changes everytime a backup occurs.  
The script will run daily to move the most current backup off to another server.
The day, month and year aren't a problem, the time (0516) presents a problem as the backup may not always finish at the same time.   I need some way to tell which is the last backup, and copy it.
 
Here is what I have so far:

Dim fs
Dim tmpYear
Dim tmpMonth
Dim tmpDay


tmpYear= Year(Date())
if tmpYear < 99 then tmpYear = tmpYear +2000

tmpMonth= Month(Date())
if tmpMonth < 10 then tmpMonth = "0" & tmpMonth

tmpDay= Day(Date())
if tmpDay< 10 then tmpDay= "0" & tmpDay



set fs = CreateObject ("Scripting.FileSystemObject")

fs.copyfile "d:\SQL BACKUPS\75 CTX\ctx_db_" & tmpYear & tmpMonth & tmpDay & "0516" & ".BAK", "d:\testdb\75CTX.BAK", True
set fs = nothing


Can I use wildcards for the time along with the string concatenation? If so how?
Should I be going about this in a completely different manner?

Thanks for any advice...


SKurj
« Last Edit: June 28, 2004, 12:39:26 PM by SKurj »