Skip to content

Commit

Permalink
Added instructions for automated move and copy
Browse files Browse the repository at this point in the history
  • Loading branch information
ezrarieben authored Sep 11, 2018
1 parent 5edafd3 commit aed8af0
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# mssql-backup-vbs
A VBScript to generate a backup file of a MS SQL database
## Configuring VBScript
> **NOTE:** By default the script uses the user executing the script to authenticate to the DB server. If you want to authenticate to the DB server using SQL Server Authentication set the options `DBUser` and `DBPass` (Line 7-8)
> **NOTE:** By default the script uses the user executing the script to authenticate to the DB server. If you want to authenticate to the DB server using SQL Server Authentication set the options `DBUser` and `DBPass` (Line 47 & 48)
1. Edit `mssql_backup.vbs`
2. Set the required options (Line 2-3)
2. Set the required options (Line 32-34)
```vbs
const ServerName = "[name of ms sql server]\[name of sql service]"
const BackupDir = "[folder path]"
const DBName = "[db name]"
```
3. Execute `mssql_backup.vbs` to generate backup

## Automated Backups with Task Scheduler
## Automated backups with task scheduler
1. Place the `start_backup.bat` file into the same directory as the `mssql_backup.vbs` script
2. Edit `start_backup.bat` and make sure the filename defined is the same as the VBScript's filename (Line 2)
```batch
Expand All @@ -20,3 +20,22 @@ SET fileName= [filename]
3. Open Windows Task Scheduler
4. Create a new task that executes the batch file with the corresponding user for the DB
> **NOTE:** The user that executes the backup script doesn't matter if you plan to use SQL Server Authentication
## Automatically copy backup on completion
1. Set the `CopyOnCompleteBool` to `true` (Line 36)
2. Set the path of the folder to copy the backup into to the variable (Line 37)
```vbs
const CopyOnCompleteBool = [true|false]
const CopyOnCompleteDir = "D:\bar"
```
3. Execute `mssql_backup.vbs`

## Automatically move backup on completion
1. Set the `MoveOnCompleteBool` variable to `true` (Line 39)
2. Set the path of the folder to copy the backup into to the variable `MoveOnCompleteDir` (Line 40)
```vbs
const MoveOnCompleteBool = [true|false]
const MoveOnCompleteDir = "D:\bar"
```
3. Execute `mssql_backup.vbs`
> **NOTE:** If both `CopyOnCompleteBool` and `MoveOnCompleteBool` are set to true, the script will make a copy of the .BAK file first and then move it to the desired location.

0 comments on commit aed8af0

Please sign in to comment.