Quantcast
Channel: SQL Server High Availability and Disaster Recovery forum
Viewing all articles
Browse latest Browse all 4689

Need a Powershell Script when my backups moved to Network drive

$
0
0
HI,

I have a backup job with 2 steps. Step1: Backup the database
Step2: Copy those backup files to Network drive.
Now I my problem is if any mistakes in powershell script it won't run, but SQL server send notification mail Job success, So I need an powershell script when the entire script ran successfully it'll send an email as " COPIED success" Else "Copy Failed - Include powershell message"

My Powershell script:

$path = "E:\Backup"
$des = "\\Network ip\Backup-DR\"
$today = get-date -Format yyyyMMdd
forfiles /p $des /s /m *q* /c "cmd /c Del @path" /d -1
robocopy $path *FULL* $des /e /maxage:$today /XD *LOG*

Viewing all articles
Browse latest Browse all 4689

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>