forked from rubrikinc/rubrik-scripts-for-powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsql-export-example.ps1
More file actions
20 lines (15 loc) · 782 Bytes
/
sql-export-example.ps1
File metadata and controls
20 lines (15 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#Authenticate to Rubrik cluster
Connect-Rubrik -Server <Rubrik IP>
#Set variables
$SourceSQLHost = 'FOO'
$SourceSQLInstance = 'MSSQLSERVER'
$dbname = 'BAR'
$TargetSQLHost = 'DEST'
$TargetSQLInstance = 'MSSQLSERVER'
#Get database object and last snapshot
$db = Get-RubrikDatabase -Hostname $SourceSQLHost -Instance $SourceSQLInstance -Database $dbname | Get-RubrikDatabase
$lastsnap = Get-RubrikSnapshot -id $db.id | Sort-Object date -Descending | Select-Object -First 1
#Get target instance ID
$targetinstance = (Get-RubrikDatabase -Hostname poc-sql02.rangers.lab -Instance MSSQLSERVER)[0].instanceId
#Run export
Export-RubrikDatabase -id $db.id -targetInstanceId $targetinstance -targetDatabaseName $dbname -finishRecovery -recoveryDateTime $lastsnap.date -MaxDataStreams 4