Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
kenchee
Starting Member
49 Posts |
Posted - 2007-08-23 : 20:21:30
|
Hi, is there a way to retore the lastest backup automatically from a set of backups. eg. i got 5 .bak files in a folder and i got another sql server that will the backup will be restored to. i want this to be automated to choose the latest of the 5 .bak files. i know how to manually do it by choosing the backup files manually and restore it, but is there an automated way. it can be in an osql script or in EM. Ken |
|
JeBoy
Starting Member
7 Posts |
Posted - 2007-08-23 : 22:10:53
|
Hello Ken,What I do is I created VB script to read the latest backup file produce, calculated base on the date and hours. The script will read all the .bak files in the folder - then will produce a restore.sql file. Then I a have a task schedule cmd file -in it is osql cmd to use the restore.sql as input file to executed.Hope this helps!JerBoy |
 |
|
kenchee
Starting Member
49 Posts |
Posted - 2007-08-23 : 23:11:09
|
Thanks JerBoy, i thought i might need a vb script, but i was hoping to see if there's anyway in EM or osql that could do it. :) |
 |
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2007-08-23 : 23:29:18
|
You can save backup file names in sql table, and build restore statement based on that. |
 |
|
Haywood
Posting Yak Master
221 Posts |
Posted - 2007-08-24 : 12:39:49
|
You can also write stored procedures that make use of dynamic sql to perform your restores. I prefer that myself, as it allows me much more control over the restore process. When you're automating restores, you usually end up automating more than just the restore itself, there are users to resynch or drop/create, potential table updates (for different enviroments that are driven by tables).... |
 |
|
pootle_flump
1064 Posts |
|
kenchee
Starting Member
49 Posts |
Posted - 2007-08-26 : 21:29:20
|
thanks for that pootle_flump. that was exactly what i was looking for. :) |
 |
|
|
|
|