30 C
Dubai
Thursday, November 28, 2024

SQL 2014/2016 Express Daily Full Backup using PowerShell

As SQL Server Agent doesn’t function on SQL 2014 Express. We have to use scripts to do daily backup.

But Powershell SQLPS module can make things more easy for Admins.

  • DailySQLDatabaseBackup

Create a Scheduled Task in Windows Server 2012 R2

Note: Using Windows Task Scheduler to Run Power shell Scripts

image

Start Daily –

image

  • Program – PowerShell
  • Add Arguments – C:\Scripts\Sql2014Express.ps1

image


#SQL Full Backup Powershell Script

Import-Module sqlps
$Date = (Get-Date -format "MM-dd-yyyy")
$location = "C:\DatabaseBackup\DBName($date).bak"
Backup-SqlDatabase -ServerInstance Servername -Database DBName -BackupFile $location

NOTE : Please Update —
DBNAME on Line 3,line 4
ServerName on Line 4

Example – Save to PS1 and it should create new full backups in this folder without appending or overwriting.

image

Example –

image

Good to know –

Get-SqlDatabase –ServerInstance servername

image

Satheshwaran Manoharan
Satheshwaran Manoharanhttps://www.azure365pro.com
Award-winning Technology Leader with a wealth of experience running large teams and diversified industry exposure in cloud computing. From shipping lines to rolling stocks.In-depth expertise in driving cloud adoption strategies and modernizing systems to cloud native. Specialized in Microsoft Cloud, DevOps, and Microsoft 365 Stack and conducted numerous successful projects worldwide. Also, Acting as a Technical Advisor for various start-ups.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

× How can I help you?