Question about "BACKUP Database" statement

Justin Doh 880 Reputation points
2025-12-17T21:34:49.2933333+00:00

This question is very closely related to my previous post, but I am posting here again because this is little bit time sensitive.

Currently, I have pipeline completed where I use T-SQL statement as below to create a BAK file daily in Prem SQL:

BACKUP DATABASE YourDB

TO DISK = 'D:\Backups\YourDB.bak' WITH COMPRESSION;

Then, I use PowerShell script to move BAK file into Azure Storage.

This process is for an external client who is going to use that BAK file to restore into their DB.

My question is: using the top T-SQL statement, would BAK file contain most recent data daily?

Or do I have to modify anything on the T-SQL statement?

When I run that T-SQL statement, the file appears to be updated daily (with most recent date and time stamp), so I assume it gets all data needed, but I am not sure that is true or not.

I would appreciate for your feedback.

SQL Server | SQL Server Transact-SQL
0 comments No comments
{count} votes

Answer accepted by question author
  1. Erland Sommarskog 129.1K Reputation points MVP Volunteer Moderator
    2025-12-17T22:07:03.97+00:00

    As I answered in the previous thread: With that exact command, the file will include the most recent backup and all previous backups written to the same file. This can sometimes be useful, but it is more likely to cause confusion. And make the file too large.

    Add INIT to avoid this:

    BACKUP DATABASE YourDB
    TO DISK = 'D:\Backups\YourDB.bak' WITH COMPRESSION, INIT;
    
    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Q&A Assist
    2025-12-17T21:35:00.4366667+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    Yes, using the T-SQL statement you provided, the BAK file will contain the most recent data from the database at the time the backup is executed. The command:

    BACKUP DATABASE YourDB
    TO DISK = 'D:\Backups\YourDB.bak' WITH COMPRESSION;
    

    creates a full backup of the database YourDB, and since you are running this command daily, each backup will reflect the state of the database at the time of the backup. The updated timestamp on the BAK file indicates that the backup process is successfully overwriting the previous file with the latest data.

    You do not need to modify anything in your T-SQL statement for it to capture the most recent data; it is functioning as intended. Just ensure that the backup process is scheduled to run daily without interruptions to maintain the most current data in the BAK file.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.