mssqltips logo

Creating a backup using SQL Server Command Line (T-SQL)



By:
Overview

Creating command line backups is very straightforward.  There are basically two commands that allow you to create backups, BACKUP DATABASE and BACKUP LOG.

Explanation

Here are some simple examples on how to create database and log backups using T-SQL.  This is the most basic syntax that is needed to create backups to disk.

Create a SQL Server full backup

BACKUP DATABASE AdventureWorks 
TO DISK = 'C:\AdventureWorks.BAK'
GO

Create a SQL Server transaction log backup

BACKUP LOG AdventureWorks 
TO DISK = 'C:\AdventureWorks.TRN'
GO

This is basically all you need to do to create the backups.  There are other options that can be used, but to create a valid and useable backup file this is all that needs to be done.

To read more about these options take a look at these topics:


Last Update: 3/12/2009




More SQL Server Solutions











Post a comment or let the author know this tip helped.

All comments are reviewed, so stay on subject or we may delete your comment. Note: your email address is not published. Required fields are marked with an asterisk (*).

*Name
*Email
Email me updates

Signup for our newsletter

I agree by submitting my data to receive communications, account updates and/or special offers about SQL Server from MSSQLTips and/or its Sponsors. I have read the privacy statement and understand I may unsubscribe at any time.





Wednesday, May 02, 2018 - 6:28:06 AM - MAHASE THIBELI Back To Top

 How to restore corrupted database using sql commnads?

 


Tuesday, April 03, 2018 - 12:40:44 PM - Anwar Zahid Back To Top

 Very helpful. Nice organized.

 



download





get free sql tips

I agree by submitting my data to receive communications, account updates and/or special offers about SQL Server from MSSQLTips and/or its Sponsors. I have read the privacy statement and understand I may unsubscribe at any time.



Learn more about SQL Server tools