Automated Log Shipping Setup for Numerous User Databases
<# Install-Module dbatools Import-Module dbatools -Force #>
<# Pre-create backup and copy folder structure for each database \\server\logship\db1 \\server\logship\db2 \\server\logship\db3 \\server\logship\COPY\db1 \\server\logship\COPY\db2 \\server\logship\COPY\db3 #>
CLS $Databases = "ADMIN", "ADMIN2", "ADMIN3" # Configure Log Shipping. foreach ($Database in $Databases) { $params = @{ SourceSqlInstance = 'p-gcp-sql-01\mxp' DestinationSqlInstance = 'p-gcp-sql-02\mxp' Database = $Database RestoreDataFolder = 'S:\MSSQL\' RestoreLogFolder = 'L:\MSSQL\' SharedPath= '\\p-gcp-sql-03\LOGSHIP' #Network Path to Backup Folder | Retention is 3 days | Alert if > 60minutes BackupScheduleFrequencyType = 'daily' BackupScheduleFrequencyInterval = 1 #Daily Every 15minutes 24/7/365 CompressBackup = $true CopyScheduleFrequencyType = 'daily' CopyScheduleFrequencyInterval = 1 #Daily Every 15minutes 24/7/365 GenerateFullBackup = $true RestoreScheduleFrequencyType = 'daily' RestoreScheduleFrequencyInterval = 1 #Daily Every 15minutes 24/7/365 Alert if > 45minutes SecondaryDatabaseSuffix = '_LS' CopyDestinationFolder = '\\p-gcp-sql-03\logship\copy' #Network Path to Copy Folder | Retention is 3 days | Alert if > 60minutes NoRecovery = $true } Write-Host "Log Shipping Setup Started >>> " $Database Start-Sleep -Seconds 5 Invoke-DbaDbLogShipping @params -Verbose }
|
|
|
|
|