Call Us: US - +1 845 478 5244 | UK - +44 20 7193 7850 | AUS - +61 2 8005 4826

Backing Up an SQL Database

Overlap with Windows Commands

When you’re new to PowerShell it can feel overwhelming to try and learn a whole new library of commands. However, what most new users don’t realize is that the syntax used on Windows command-line overlaps with PowerShell. This is made easier by the fact that PowerShell isn’t case sensitive.

Much like Command Prompt, on PowerShell the cd command still changes directories, and dir still provides a list of files within the selected folder. As such, it’s important to remember you aren’t necessarily starting from scratch. Taking this onboard will help to decrease the learning curve you face when using PowerShell and decrease the amount of new commands that you have to learn.

That being said, it is important to note that these aren’t considered complete PowerShell commands so much as they are aliases (Powershell’s name for Windows command prompt commands). So even though you can try some of Command Prompt’s commands in PowerShell, you should learn as much as you can about the new ones. Nonetheless, Command Prompt experience can definitely help new users to come to grips with PowerShell and hit the ground running.

. Backing Up an SQL Database

powershell SQL

Many people use PowerShell to back up SQL databases. The command-line interface can conduct full database backups, file backups, and transaction log backups. There are many ways to backup a database in PowerShell, but one of the simplest is to use the Backup-SqlDatabasecommand. For example:

PS C:\> Backup-SqlDatabase -ServerINstance “Computer\Instance” -Database “Databasecentral”

This will create a database backup of a database with the name ‘Databasecentral’ (or the name of your chosen database’.