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


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


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

TO DISK = 'C:\AdventureWorks.BAK'

Create a SQL Server transaction log backup

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

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:

Comments For This Article

Wednesday, May 2, 2018 - 6:28:06 AM - MAHASE THIBELI Back To Top (75839)

 How to restore corrupted database using sql commnads?


Tuesday, April 3, 2018 - 12:40:44 PM - Anwar Zahid Back To Top (75592)

 Very helpful. Nice organized.


get free sql tips
agree to terms