I am applying log shipping to a database using Invoke-DbaDbLogShipping
, and i am following the example in the documentation. The jobs get created and the Database is restored on the secondary server instance from what it appears, yet the jobs are failing. This is what the Backup job log states:
Backing up transaction log. Primary Database: 'Test14' Log Backup File: 'C:\Users...\Documents\DB Log Shipping\Backups\Local\Test14\Test14_20210822193000.trn' Error: Could not log history/error message.(Microsoft.SqlServer.Management.LogShipping) Error: Failed to convert parameter value from a SqlGuid to a String.(System.Data) Error: Object must implement IConvertible.(mscorlib) First attempt to backup database 'Test14' to file 'C:\Users...\Documents\DB Log Shipping\Backups\Local\Test14\Test14_20210822193000.trn' failed because Cannot open backup device 'C:\Users...\Documents\DB Log Shipping\Backups\Local\Test14\Test14_20210822193000.trn
Why is it failing?
Here is my script:
$params = @{
SourceSqlInstance = $PrimaryServerInstance
DestinationSqlInstance = $SecondaryServerInstance
Database = $DatabaseName
GenerateFullBackup = $true
BackupNetworkPath = $SharedPath
BackupLocalPath = $LocalPath
CompressBackup = $true
Standby = $true
BackupScheduleFrequencyType = 'daily'
BackupScheduleFrequencyInterval = 1
CopyScheduleFrequencyType = 'daily'
CopyScheduleFrequencyInterval = 1
RestoreScheduleFrequencyType = 'daily'
RestoreScheduleFrequencyInterval = 1
CopyDestinationFolder = $TransactionLogsCopyPath
Force = $true #Ignore some errors in the parameters and assume defaults. It will also remove the any present schedules with the same name for the specific job.
}
Invoke-DbaDbLogShipping @params
I resolved the issue!
At C:\Users\...\Documents\DB Log Shipping\Backups\Local
there was no Test14
directory created. I created the folder Test18 manually, and the backup is now succeeding.
However, this is insane, because the Invoke-DbaDbLogShipping
should have created the Test18 folder AUTOMATICALLY when i executed the command. Apparently its only creating the folder under the $SharedPath
and $TransactionLogsCopyPath
but NOT $LocalPath
.
For automation purposes, I ended up just setting the local path to the $SharedPath