Using SQL Server 2008 through to 2014, I know how to backup and restore a database with Change Data Capture enabled (CDC), but what I am looking for is a way to query a full backup file to determine if it contains CDC data.
What would be great would be a way like RESTORE FILELISTONLY
that gets the file list from the database, but instead gets the CDC status to determine if the restore will need to use the KEEP_CDC flag?
Is there a way to determine if a backup contains CDC data?
thanks!
Best Answer
(if someone finds a way - which I dont think exists, I will delete my answer :-))
I dont think that there is any way to know from a backup, if CDC is enabled or not.
The most you can know if the database was involved in replication (under the hood uses log reader agent that scans the Transaction log) or not by using DatabaseBackupLSN in the result of
RESTORE HEADERONLY
DatabaseBackupLSN as is the “begin of checkpoint” that is triggered when the backup starts. This LSN will coincide withFirstLSN
if the backup is taken when the database is idle and no replication is configured.I assume the reason that microsoft does not surface whether CDC is enabled or not, might be a security thing as well. CDC is an enterprise level technology that enables tracking of changes all the way down to the column level. This is required by regulations like HIPAA, FISMA, etc.
From Restoring or Attaching a Database Enabled for Change Data Capture