I have a transaction backup job which runs every hour.
First it runs a backup of the database log to another drive, then it shrinks the log and deletes old
The middle task shrinks the log fle, using this code:
USE myDB DBCC SHRINKFILE('myDB_LOG', 0, TRUNCATEONLY)
However, sometimes I received the following error.
Description: Executing the query "USE myDB DBCC SHRINKFILE('myDB_LOG'..." failed with the following error: "Backup, file manipulation operations (such as ALTER DATABASE ADD FILE) and encryption changes on a database must be serialized. Reissue the statement after the current backup or file manipulation operation is completed. Changed database context to 'myDB'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly. End Error DTExec: The package execution returned DTSER_FAILURE (1). Started: 22:00:19 Finished: 22:04:17 Elapsed: 238.26 seconds. The package execution failed. The step failed.
Why is this happening?
Is there a better way to backup and shrink the database log?