sqlbackup support RESTORE HEADERONLY to find logical names?
jerryhung
Posts: 138
I am modifying my auto-restore scripts to use with SQL Backup extended procedures
I currently use a procedure [usp_RestoreFromAllFilesInDirectory] to restore all backup files under a directory
I use RESTORE WITH FILELISTONLY and RESTORE HEADERONLY to find the logical name and etc
this way, I can restore ALL files inside a folder (BAK/DIFF/TLOG) without having to worry about their Logical Names or File names
Is there such option for the sqlbackup procedure?
I currently use a procedure [usp_RestoreFromAllFilesInDirectory] to restore all backup files under a directory
I use RESTORE WITH FILELISTONLY and RESTORE HEADERONLY to find the logical name and etc
this way, I can restore ALL files inside a folder (BAK/DIFF/TLOG) without having to worry about their Logical Names or File names
Is there such option for the sqlbackup procedure?
EXECUTE master..sqlbackup '-SQL "RESTORE DATABASE [db] FROM DISK = ''"E:\Backup\db_production.sqb'' WITH NORECOVERY , MOVE ''data'' TO ''E:\MSSQL\DATA\db.mdf'' , MOVE ''log'' TO ''E:\MSSQL\LOG\db.ldf''"'
Jerry Hung
DBA, MCITP
DBA, MCITP
Comments
automated restores are something that I would love to see integrated into SQLBackup and being able to use these would be a good move towards it.
Jonathan
Senior DBA
Careers South West Ltd
Thanks
DBA, MCITP
May I request a reply?
or, who can I contact to ask this question as we have 1-year support, thanks?
Thanks in advance
DBA, MCITP
The forum is for community support, although we do moderate it, and in fact do end up answering most of the new topics. Since you had a reply to this topic, we did not raise a support incident for it.
If you have a support contract, please contact us directly by phone or email.
SQL Backup does have the RESTORE FILELISTONLY, RESTORE HEADERONLY and RESTORE SQBHEADERONLY syntax which can be used as normal something like this:
EXECUTE master..sqlbackup '-SQL "RESTORE FILELISTONLY FROM DISK = ''E:\Backup\mybackup.sqb''"'
Info can also be found here at the bottom and here.
If using this as part of a script, you may also want to use the SINGLERESULTSET option so the details returned are easily readable by your script.
I hope that helps.
Redgate Foundry
The recently released version 6.3 goes some way towards achieving this. The following syntax:
will cause SQL Backup to look in its backup history records and simply restore the latest full backup that it finds. You can also use LATEST_DIFF to restore the latest differential backup, but the state of your database obviously needs to be in a non-recovery/read-only state, and is the correct base backup for the latest differential restore.
Another point to note is that RESTORE ... FROM BACKUPHISTORY only works if you are restoring on the server instance where the backup was created, since that is where the backup history records reside. If you are restoring on another server instance, you can use the following:
will cause SQL Backup to find all files matching the AdventureWorks* search pattern in the g:\backups\ folder, determine the latest complete full backup set that's available, and restore it. Again, LATEST_DIFF is also available here.
One last point is that all the other restore options can still be used with the above syntax e.g. MOVE, NORECOVERY, STANDBY etc.
Thanks.
SQL Backup Consultant Developer
Associate, Yohz Software
Beyond compression - SQL Backup goodies under the hood, updated for version 8
Error 507: No valid backup sets found from provided folder(s).
I have tried from a local drive and a network location with no difference. Running the full SQL Backup script with the file name explicitly named works fine from both locations ... Can you give me any further advice please?
[Edit: I'm using v6.3.0.48]
[Edit 2: oddly, this works;]
EXEC master..sqlbackup '-sql "RESTORE DATABASE [RESTORE_AdventureWorks] FROM BACKUPHISTORY = [adventureworks] LATEST_FULL with recovery ....
regards
Jonathan
Senior DBA
Careers South West Ltd
Thanks.
SQL Backup Consultant Developer
Associate, Yohz Software
Beyond compression - SQL Backup goodies under the hood, updated for version 8
This also fails - with a local file location
they both give the same error message to I took that to mean the network share is a valid option... :-/
Both locations only had SQL Backup full backup files for the adventureworks database from the last 4 days.
Senior DBA
Careers South West Ltd
This is a known issue (SB-4445), and is under consideration for a fix in a future release.
SQL Backup Consultant Developer
Associate, Yohz Software
Beyond compression - SQL Backup goodies under the hood, updated for version 8
We run trial restores of our backups on a development server and prefix the database names with "RESTORE_" so that we know which they are and can drop them safely once the restore is done.
It looks like I need the database rename part of one format and the 'cross server' ability to get to the network share of the other format!!
Oh well, I'll hang on for the full(er) functionality from the future release.
thanks again
Senior DBA
Careers South West Ltd