6

Backstory: I'm trying to restore copies of several SQL 2012 databases to a different environment, but the application needs them to be (roughly) "synchronized" in time.

(Of course the ideal way to do this is by using FULL recovery mode using full and log backups, and then do point-in time restores using the same timestamp. But in my case, I don't need them perfectly synchronized, just within ~10 minutes or so, and I'd rather deal with only full backups and restores. I do have control over when the full backups run, but the problem is that the databases are of very different sizes, so the full backups run for very different lengths of time.)

So my question: should I synchronize the start time of the full backups? Or the finish time?

In other words, when I restore a full backup, will I end up with how it looked when the backup started, or when it finished?

BradC
  • 10,073
  • 9
  • 51
  • 89

3 Answers3

10

Check out this link

A full database backup provides a complete copy of the database and provides a single point-in-time to which the database can be restored. Even though it may take many hours for the backup process to run, you can still only restore the backup to a single point (effectively at the end of the backup, but I'll discuss exactly what that point is later in this article). A full backup does not allow recovery to any point in time while the backup was running.

pacreely
  • 1,098
  • 1
  • 7
  • 15
6

A Sql Server backup contains all allocated data pages and enough of the transaction log so a restore operation can recover the database so it is transactionally consistent as of the point in time when the read data operation completed.

So, to answer your question

What is the “moment” of a full backup? The START time or the FINISH time?

It's the FINISH time.

It should be very easy to prove this to yourself by invoking a backup operation, making some changes to some data while the backup is running (making sure to commit them) and then restore that backup somewhere and check for your changes.

Referencing More on how much transaction log a full backup includes

Scott Hodgin - Retired
  • 24,062
  • 2
  • 29
  • 52
0

Any SQL backup is done when it writes the backup end time to the backupset table in the msdb database. When you search in there full backups are type D and log backups are type L. And there is a copy-only column to mark copy-only backups

I run the following query periodically against a group I created on our central management server and you can modify it for your needs.

select  a.server_name as hostname,   a.Database_Name,a.name, 
a.backup_finish_date
--over (partition by database_name) 
as Backup_End_Time
,Backup_Type = 
case a.type
when 'D' then 'Full backup'
when 'I' then 'Differential Backup'
when 'L' then 'Transaction Log Backup'
when 'F' then 'filegroup Backup'
when 'G' then 'Differential File backup'
else 'See Books Online'
end, cast((a.backup_size/1048576)as bigint) as Size_of_Backup_MB , 
a.software_major_version, a.compatibility_level, a.has_backup_checksums, 
a.is_copy_only
from msdb..backupset a
inner join sys.dm_hadr_availability_replica_cluster_states b on 
a.server_name = b.replica_server_name
--inner join sys.dm_hadr_availability_replica_cluster_states e on 
d.server_name = e.replica_server_name
inner join sys.dm_hadr_availability_replica_states c on c.replica_id = 
b.replica_id
inner join sys.databases e on a.database_name = e.name
where exists 
(select 1 from msdb..backupset d
            where a.server_name = d.server_name 
                and a.database_name = d.database_name
                and d.is_copy_only = 0
                having a.backup_finish_date = max(d.backup_finish_date))
 and a.Type = 'd'
 --and a.name in ('CommVault Galaxy Backup')
 --and a.has_backup_checksums = 0
 --and c.role_desc = 'primary'
 group by a.backup_finish_date, a.database_name, a.server_name, a.Type, 
 a.backup_size, a.compatibility_level, a.database_version, 
 a.software_major_version
 , a.has_backup_checksums, a.is_copy_only, a.name, a.description
 having max(a.backup_finish_date) < getdate() -2
 order by a.server_name, a.database_name  
Alen
  • 539
  • 3
  • 9