You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Restore-CohesityRemoteMSSQLObject-Wrapper.ps1 is newly to Restore the DB (#178)
* Restore-CohesityRemoteMSSQLObject-Wrapper.ps1 is newly to Restore the DB
based on SqlHost, SqlObjectName and TargetHost.
Restore-CohesityRemoteMSSQLObject.ps1 : DbRestoreOverwritePolicy option
is newly added
* Updated markdown file for MSSQL remote restore.
* Included switch parameter to return result as object.
---------
Co-authored-by: KavishreeShanmugam11 <kshanmugam.maplelabs@cohesity.com>
Restore MSSQL database from remote cluster with database id 1279 , database instance id 1277 and job id as 31520
45
+
Restore MSSQL database from remote cluster with database id 1279 , database instance id 1277 and job id as 31520 with the latest recoverable snapshot information.
Restore MSSQL database from remote cluster with database name database_1 from the sql host x.x.x.x, and job id as 31520 to the target host y.y.y.y with latest recoverable snapshot information.
76
+
61
77
## PARAMETERS
62
78
63
79
### -TaskName
@@ -84,7 +100,7 @@ Type: Int64
84
100
Parameter Sets: (All)
85
101
Aliases:
86
102
87
-
Required: True
103
+
Required: False
88
104
Position: Named
89
105
Default value: 0
90
106
Accept pipeline input: False
@@ -99,7 +115,7 @@ Type: Int64
99
115
Parameter Sets: (All)
100
116
Aliases:
101
117
102
-
Required: True
118
+
Required: False
103
119
Position: Named
104
120
Default value: 0
105
121
Accept pipeline input: False
@@ -217,6 +233,51 @@ Accept pipeline input: False
217
233
Accept wildcard characters: False
218
234
```
219
235
236
+
### -SqlHost
237
+
Specifies the SQL host from which database need to be restored.
238
+
239
+
```yaml
240
+
Type: String
241
+
Parameter Sets: (All)
242
+
Aliases:
243
+
244
+
Required: False
245
+
Position: Named
246
+
Default value: 0
247
+
Accept pipeline input: False
248
+
Accept wildcard characters: False
249
+
```
250
+
251
+
### -SqlObjectName
252
+
Specifies the name of the SQL Object to be restored.
253
+
254
+
```yaml
255
+
Type: String
256
+
Parameter Sets: (All)
257
+
Aliases:
258
+
259
+
Required: False
260
+
Position: Named
261
+
Default value: 0
262
+
Accept pipeline input: False
263
+
Accept wildcard characters: False
264
+
```
265
+
266
+
### -TargetHost
267
+
Specifies the target host if the application is to be restored to a different host.
268
+
269
+
```yaml
270
+
Type: String
271
+
Parameter Sets: (All)
272
+
Aliases:
273
+
274
+
Required: False
275
+
Position: Named
276
+
Default value: 0
277
+
Accept pipeline input: False
278
+
Accept wildcard characters: False
279
+
```
280
+
220
281
### -RestoreTimeSecs
221
282
Specifies the time in the past to which the SQL database needs to be restored.
222
283
This allows for granular recovery of SQL databases.
[Parameter(Mandatory=$false)][switch]$CaptureTailLogs,# Specifies if the tail logs are to be captured before the restore operation. This is only applicable if restoring the SQL database to its hosting Protection Source and the database is not being renamed.
10
+
[Parameter(Mandatory=$false)][switch]$DbRestoreOverwritePolicy,# This field will overwrite the existing db contents if it sets to true. By default the db overwrite policy is false.
11
+
[Parameter(Mandatory=$true)][ValidateRange(1, [long]::MaxValue)][long]$JobId,# Specifies the job id that backed up this MS SQL instance and will be used for this restore
12
+
[Parameter(Mandatory=$false)][switch]$KeepCDC,# This field prevents "change data capture" settings from being reomved. When a database or log backup is restored on another server and database is recovered.
13
+
[Parameter(Mandatory=$false)][string]$NewDatabaseName,# Specifies a new name for the restored database.
14
+
[Parameter(Mandatory=$false)][string]$NewInstanceName,# Specifies the instance name of the SQL Server that should be restored.
15
+
[Parameter(Mandatory=$false)][long]$RestoreTimeSecs=0,# Specifies the time in the past to which the SQL database needs to be restored. This allows for granular recovery of SQL databases. If not specified, the SQL database will be restored from the full/incremental snapshot.
16
+
[Parameter(Mandatory=$true)][string]$SqlHost,# Specifies the SQL Host information
17
+
[Parameter(Mandatory=$true)][string]$SqlObjectName,# Specifies the SQL Object Name
18
+
[Parameter(Mandatory=$false)][string]$TargetDataFilesDirectory,# Specifies the directory where to put the database data files. Missing directory will be automatically created. This field must be set if restoring to a different target host.
19
+
[Parameter(Mandatory=$true)][string]$TargetHost,# Specifies the target host to restore
20
+
[Parameter(Mandatory=$false)][string]$TargetLogFilesDirectory,# Specifies the directory where to put the database log files. Missing directory will be automatically created. This field must be set if restoring to a different target host.
21
+
[Parameter(Mandatory=$false)][Object[]]$TargetSecondaryDataFilesDirectoryList# Specifies the secondary data filename pattern and corresponding directories of the DB. Secondary data files are optional and are user defined. The recommended file extension for secondary files is ".ndf". If this option is specified and the destination folders do not exist they will be automatically created. This field can be set only if restoring to a different target host.
22
+
)
23
+
24
+
# Check if specified job exists
25
+
$job=Get-CohesityProtectionJob-Ids $JobId
26
+
if (-not$job) {
27
+
Write-Output"Cannot proceed, the job id '$JobId' is invalid"
28
+
return
29
+
}
30
+
31
+
$HostSourceId
32
+
$JobRunId
33
+
$SourceId=0
34
+
$StartTime
35
+
$TargetHostId=0
36
+
37
+
# Get the list of SQL objects that can be restored and fetch the id of the specified SQL host
0 commit comments