Batch Files

Baz

Baz

Soldato
Joined
9 Dec 2002
Posts
4,375
Location
Peterborough
Some help needed if you please..

I have a backup file that is created every few hours, just after it is created I want to move it automatically to a different server, the file created is named as so "db_200604251300.BAK" the next one being "db_200604251700.BAK" and so on.

How can i create a batch file to copy the latest one across...?


Ta muchly :D
 
as long as the location you want to copy it to (or from) is a mapped drive then just put the command 'copy <source file> <target file>' in a plain textfile called copy_files.bat and run that file.

Do you want to copy it or move it?

HT
 
then you should be able to use wildcard * after the 2006 as this only changes at the end of the year and the batch file should automatically move anything named "db_2006******"
 
that will move all the files

you'll need to construct the date string, I presume that the final part of the file name is the time of the backyup? 1300, 1700, 2100 etc?

you could do a for loop through all the files in the directory ordered by date / time and only call the copy command for the latest file. How do you generate the filenames currently?

why not get the same process that starts the backup to do the copy functionality as well?

HT
 
happytechie said:
why not get the same process that starts the backup to do the copy functionality as well?
That's the best idea because you can't totally rely on the backup being finished/correct before you begin the copy process, which just gets ugly.
 
Beansprout said:
That's the best idea because you can't totally rely on the backup being finished/correct before you begin the copy process, which just gets ugly.

If you absolutely need to use a seperate archive process you should get the file that creates them to produce a 'signal' file - an empty file that indicates its currently doing something, that the process deletes when its finished. Criude but effective
 
Cheers guys, had a blonde moment after reading the replies, I can just get the application to move the file... *slaps head*

never mind, ta anyway :)
 
Back
Top Bottom