How can I estimate how much storage will Point in Time Restore consume for a single instance of Azure SQL database? We want to switch from DTU to VCore model and I need to do some estimates for the management.
I am aware that this depends largely on the number of transactions that DB has, but I got some really worrying answers from MS support, so maybe someone with more hands-on experience can help me.
Let's say that I have a 100GB database with 7 days PiTR enabled. Roughly speaking, how much storage will this feature induce?
Thanks.
(I'll preface my answer with some exposition)
Point-in-Time-Restores (PITRs) work by first restoring the most recent Full backup, then applying differential/incremental restores on-top, followed by replaying the Transaction Log backups. Azure SQL maintains these backups for you and stores them together in their managed Azure SQL backup storage area.
PITR restores are handled separately from LTR (Long Term Retention) backups and restores, and LTR backups/restores are out-of-scope of this StackOverflow QA.
Creating and maintaining the backup files, and performing a restore, is fully managed by Azure - so you don't get to have any access to the raw files (which is probably a good thing).
Azure SQL DTU databases cost a flat monthly fee which includes the cost of PITR backups, up to the 35-day limit.
Azure SQL vCore databases charge around $0.12 USD/GB/month for LRS storage of PITR backup data.
(My answer ignores Azure SQL Hyperscale databases, which implement PITR backups in a very different way compared to other Azure SQL SKUs - so if you're thinking of using Azure SQL vCore General Purpose or Azure SQL vCore Business Critical then this answer should help you)
First, ensure you've read the current Backup storage consumption documentation, which my answer is based on.
SELECT SUM( a.used_pages * 8192 ) AS TotalSizeInBytes FROM sys.allocation_units AS a
.SELECT SUM( a.used_pages * 8192 ) AS TotalSizeInBytes, ( SUM( a.used_pages * 8192 ) / 3 ) AS CompressedFullBackupSizeEstimate FROM sys.allocation_units AS a
SELECT modified_extent_page_count FROM sys.dm_db_file_space_usage
.SELECT ( modified_extent_page_count * 8192 ) / 3 AS NextCompressedDifferentialBackupFileSizeEstimate FROM sys.dm_db_file_space_usage
- if that differential-backup file were to be made at this very instant in time.[ 15MB, 31MB, 46MB, 62MB, 78MB, 93MB, 109MB ]
for each of those 7 days, respectively.delta_log_bytes_used
insys.dm_resource_governor_workload_groups_history_ex
; if there's insufficient history then you'll need to monitor how the log-file grows before it's truncated (which can be done withlog_space_in_bytes_since_last_backup
insys.dm_db_log_space_usage
- orsys.dm_db_log_stats ( database_id )
Well, if zero writes happen to your 100GB database at all, then your PITR will only need 100GB for the Full-backup as the Differential and Txn-Log backups will all be empty because nothing happened...