Does "RESTORE LABELONLY" work with .sqb file?

Task: Redgate created bakup in split file. So i have 4 sqb files.
We need to create dynamic restore script and restore db on SQL instance.

I want to figure out how many sqb files backup has?, in this case it should be 4.

We are passing first sql file as parameter
I am using below command
EXEC MASTER..SQLBACKUP '-SQL "RESTORE LABELONLY FROM DISK = ''D:\backups\bfile_1.sqb''

It seems labelonly does not work

I am getting below result. 
Syntax error: 'LABELONLY' after 'RESTORE'
exitcode 850
sqlerrorcode 0

Any help?
Tagged:

Best Answer

  • petey2petey2 Posts: 88 Silver 3
    SQL Backup does not support the RESTORE LABELONLY syntax.  The workaround is to use the RESTORE SQBHEADERONLY syntax, with the SINGLERESULTSET option and read the 4th line (File number) e.g.

    EXEC master..sqlbackup '-sql "RESTORE SQBHEADERONLY FROM DISK = [d:\backups\bfile_1.sqb] WITH SINGLERESULTSET"'

    If there is only a single backup set in that folder, or if the files making up the backup set can be identified via a search pattern, you can use a wildcard search e.g.

    EXEC master..sqlbackup '-sql "RESTORE DATABASE db1 FROM DISK = [d:\backups\bfile_*.sqb] WITH REPLACE"'

    If you have multiple backup sets in that folder, and all you want to do is to restore the latest full backup for a particular database, you can use the LATEST_FULL option.  SQL Backup will collect all the relevant files and restore them for you, without you having to provide the names of each individual file e.g.

    EXEC master..sqlbackup '-sql "RESTORE DATABASE db1 FROM DISK = [d:\backups\bfile*.sqb] LATEST_FULL WITH REPLACE"'

    SQL Backup will look in the d:\backups\ folder, find all files matching the bfile*.sqb pattern, find the latest available backup set for the db1 database, collect all the backup files making up that backup set, and perform the restore.

    If the name of the restored database differs from the source database, use the SOURCE option to provide the name of the source database e.g.

    EXEC master..sqlbackup '-sql "RESTORE DATABASE db1_reporting FROM DISK = [d:\backups\bfile*.sqb] SOURCE = [db1] LATEST_FULL WITH REPLACE"'

    Here, SQL Backup will restore the database as db1_reporting, but will look for backup files created for the db1 database.

    Note that there are also LATEST_DIFF and LATEST_ALL options to automate restore tasks.
    SQL Backup - beyond compression

Answers

Sign In or Register to comment.