Dear friends,
I would like to build a dynamic restore scripts. The problem is i can't know the original File Groups within the new created SQB file.
I can see the SQL Backup gui doe's it, i guess maybe it uses the catalog repository. Anyway, i assume i do not have this repository and neither the backed up sql database.
My question is: how can i know what File Groups are contained within my SQB file , in order to script their new locations?
chenchen
0

Comments

1 comment

  • petey
    Try
    EXEC master..sqlbackup '-sql "RESTORE FILELISTONLY FROM DISK = [<backup file name>] WITH SINGLERESULTSET"'
    
    If you're fine with moving all data files to the same folder, and all log files to the same folder, you can use the DATAFILES and LOGFILES shortcuts e.g.
    EXEC MASTER..sqlbackup '-sql "RESTORE DATABASE mydb FROM DISK = [<backup file name>] WITH MOVE DATAFILES TO [<data files folder>], MOVE LOGFILES TO [<log files folder>"'
    
    In this way, you don't need to know the actual filegroup names.
    petey
    0

Add comment

Please sign in to leave a comment.