Overview
With this method, Artie reads changes from your transaction log backups (.trn files) as they land in a shared location, instead of from the live database.
Requirements
- Database recovery model must be set to
FULLorBULK_LOGGED - Transaction log backups taken on a schedule, uncompressed, to a location Artie can read
- Each replicated table must have a primary key
- Each replicated table should have supplemental logging enabled (see below)
Supplemental logging
By default, SQL Server logs only the bytes anUPDATE changed. For those tables, Artie looks the row up in the database when it reads the backup, so the message carries the row as it is at that point rather than as of the update. An update of a row deleted since is then lost.
With supplemental logging, SQL Server logs the whole row for every update, and Artie reads updates straight from the backup. Enable it on each table in one of two ways:
- CDC (recommended)
- Transactional publication
EXEC msdb.dbo.rds_cdc_enable_db 'DATABASE_NAME'; instead of sys.sp_cdc_enable_db.is_replicated should be 1 for each table:
Letting the log truncate
Both options mark every transaction on these tables for replication, and SQL Server keeps it in the log until something marks it as distributed. Without the CDC capture job or a Log Reader Agent,log_reuse_wait_desc in sys.databases stays at REPLICATION and the log keeps growing, even with regular log backups.
Since Artie reads your log backups, it is safe to mark everything as distributed on a schedule; each log backup still contains every change. Schedule this with SQL Server Agent:
REPLICATION for over an hour.
Things to know
TRUNCATE TABLEis not allowed on tables tracked by CDC or published for replication.- Columns stored off-row (such as large
VARCHAR(MAX)values) are not in the log with the rest of the row, so Artie still reads them from the database. If the row has been deleted by then, those columns keep their current values in the destination.