top of page

Poweshell program for Backup databases from PROD to TEST environment in MS SQL2016

Hi guys, We have not seen you for ages!

Today, I will write about backuping in powershell. I often have to deals with with development depatment refresh databases from production environment to testing environment, almost on daily bases. Therefore I wrote small script that have 40 rows.

As you can see, you have to fill in SQL instance, three databases and destination share folder for .bak files.

There is condition, if you have not filled in database name script write only 'Empty'

Here is entire script:

The course looks like this:

Running backup by powershell

This script save me a lot of time, because can use only developers and I do not have to deal with anything. I have created new account that have only role - db_backupoperator. Therefore developers can run under this account and .bak files are saved in testing env..

To be honest, I'm not a native developer :D But it works!


bottom of page