PowerProtect Microsoft Application Agent 19.13 SQL Server User Guide

Restore SQL Server databases with T-SQL scripts

The Microsoft application agent for Storage Direct enables you to generate SQL-CLR script that you can use to restore SQL Server databases.

The SQL-CLR restore command is protectpoint_run_restore.

You must provide a VARCHAR type parameters to this command. The protectpoint_run_restore command uses the same command options as the msagentrc.exe command. Optional parameters for database-level restores with the msagentrc.exe command provides information about the restore command options.

You can use any SQL Server standard interfaces such as, the SQL Server Management Studio Query window and T-SQL command prompt to run the SQL-CLR scripts.

Sample T-SQL restore script

USE [master]
GO
DECLARE @returnCode int
DECLARE @stdin NVARCHAR(MAX)
SET @stdin = '-t 1465210308 -A ADDITIONAL_RESTORES=no -A
RENAME_TO=dbtest3 -A "RELOCATE_TO='E:\MSSQL12.MSSQLSERVER00001\MSSQL
\DATA\Customers.mdf'='F:\NewData', 'E:\MSSQL12.MSSQLSERVER00001\MSSQL
\DATA\Customers_log.ldf'='G:\NewLogs' "APPLICATIONS:\SqlServerWriter
\LEDMF176%5CMSSQLSERVER00001\TestDB1\"' + CHAR(10) + '-t 1465210307 -A
ADDITIONAL_RESTORES=no "APPLICATIONS:\SqlServerWriter
\LEDMF176%5CMSSQLSERVER00001\dbtest2\"' + CHAR(10) + '-t 1465210306 -A
ADDITIONAL_RESTORES=no "APPLICATIONS:\SqlServerWriter
\LEDMF176%5CMSSQLSERVER00001\dbtest1\"' + CHAR(10);
EXEC @returnCode = dbo.protectpoint_run_restore ' -A
"RESTORE_DEVICE_POOL=ledmf098_restore_pool_1" -A
"RESTORE_DEVICE_GROUP=ledmf098_DG2" -c ledmf176.msapp.com -A
"NSR_DFA_SI_DD_HOST=ledmd035.lss.example.com" -A
"NSR_DFA_SI_DD_USER=DD163_user" -A "NSR_DFA_SI_DEVICE_PATH=/SU_DD163"
-A "NSR_DFA_SI_DD_LOCKBOX_PATH=C:\Program Files\DPSAPPS\common
\lockbox" -A NSR_RESTORE_TYPE=regular -I -', @stdin
IF @returnCode <> 0
BEGIN
RAISERROR ('Fail!', 16, 1)
END

Rate this content

Accurate
Useful
Easy to understand
Was this article helpful?
0/3000 characters
  Please provide ratings (1-5 stars).
  Please provide ratings (1-5 stars).
  Please provide ratings (1-5 stars).
  Please select whether the article was helpful or not.
  Comments cannot contain these special characters: <>()\