Learning and Sharing
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
No Result
View All Result

How to Backup and Restore a SQL Database Using Command Prompt SQLCMD and T-SQL

May 23, 2022
in Blog, SQL Server
0
ADVERTISEMENT

Table of Contents

In this article I am explaining how to do backup and restore using a SQLCMD and T-SQL command prompt.

It’s one of the most important responsibilities for DBAs. It works across all supported operating systems, whether they are 64-bit or 32-bit systems. A backup scenario in SQL Server is the process of copying the data from a SQL Server database and creating a backup file. A restore scenario in SQL Server is the process of restoring data from one or more backups and then recovering the database.

Using Command Prompt or Powershell - SQLCMD

1. First, right click on Start button, then click Windows PowerShell admin.

Pw

2. For a backup enter the following in the PowerShell window. Don’t forget replace your database name and backup location.

sqlcmd -e -s touch -q "backup database KAV to disk = 'D:\Backup\KAV.bak'"
Bg101

3. To restore a database, use the following in the PowerShell window. Don’t forget replace your database name and backup location.

sqlcmd -e -s touch -q "restore database KAV from disk = 'D:\Backup\KAV.bak'" 
Bg102

Using T-SQL to backup and restore a SQL database

1. For backup a database to a file, run below command. Don’t forget replace your database name and backup location.

backup database [KAV] to disk='D:\Backup\KAV.bak'
Bg103

2. For restore a database from a backup file, run below command. Don’t forget replace your database name and backup location.

restore database [KAV] from disk='D:\Backup\KAV.bak'
Bg104

Types of SQL Server Backups

The various types of backups that you can create are as follows

  • Full backups
  • Differential backups
  • File backups
  • File group backups
  • Partial backups
  • Copy-Only backups
  • Mirror backups
  • Transaction log backups

I will explain in my next article the types of backups and how to create backups and restores.

5/5 - (1 vote)
Previous Post

How to create a backup using SQL Server Management Studio SSMS

Next Post

How to Remove Social and Promotions Categories in Gmail and See All Your Emails in One Place

Related Posts

Running Hyper-V and VMware Workstation on The Same Machine

August 15, 2024

How to Uninstall All Autodesk Products At Once Silently

July 29, 2024
Ftr5

How to Uninstall the Autodesk Genuine Service on Windows

July 29, 2024
Ftr19

How to Fix Windows Cannot Read the ProductKey From the Unattend Answer File in VirtualBox

July 26, 2024
Ftr25

How to Update Windows Terminal in Windows 10/11

July 26, 2024

How to Disable The Beep Sound in WSL Terminal on Windows

July 26, 2024

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How To Turn On uBlock Origin Extension in Chrome (2025)
  • Images Hidden Due To Mature Content Settings In CivitAI
  • Azure OpenAI vs Azure AI Hub, How to Choose the Right One for Your Needs

Categories

Stay in Touch

Discord Server

Join the Discord server with the site members for all questions and discussions.

Telegram Community

Jump in Telegram server. Ask questions and discuss everything with the site members.

Youtube Channel

Watch more videos, learning and sharing with Leo ❤❤❤. Sharing to be better.

Newsletter

Join the movement and receive our weekly Tech related newsletter. It’s Free.

General

Microsoft Windows

Microsoft Office

VMware

VirtualBox

Technology

PowerShell

Microsoft 365

Microsoft Teams

Email Servers

Copyright 2025 © All rights Reserved. Design by Leo with ❤

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory