https://github.com/rich-in-sql/sql-schema-backup
https://github.com/rich-in-sql/sql-schema-backup
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/rich-in-sql/sql-schema-backup
- Owner: Rich-In-SQL
- Created: 2022-08-30T19:14:22.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-02T06:22:12.000Z (almost 2 years ago)
- Last Synced: 2025-02-07T06:44:17.903Z (12 months ago)
- Language: PowerShell
- Size: 24.4 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Introduction
This script uses [dbatools](https://dbatools.io/) to backup database objects from a SQL Server Database to a directory of your choosing. This script is used internally to backup our databases for GitHub.
The server & database are both user defined parameters.
## Accepted Parameters
| Parameter | Data Type | Mandatory |
|---|---|---|
| database | string | Yes |
| server | string | Yes |
| SourceControlDirectory | string | Yes |
| logDirectory | string | Yes |
## Getting Started
1. Clone the code to your local workstation.
2. Navigate to the directory where the script has been cloned
3. Execute the script passing in the required parameters.
### Executing the backup script
`.\SQL-Schema-Backup.ps1 -database 'YourDatabase' -server 'YourServer' -SourceControlDirectory 'C:\Temp\' -logDirectory 'C:\Temp\Logs' -pushToGit $True`
### Executing the restore script
`.\SQL-Schema-Restore.ps1 -database 'YourDatabase' -server 'YourServer' -SourceControlDirectory 'C:\Temp\' -logDirectory 'C:\Temp\Logs'`
### Notes
These scripts make use of [smo.scriptingoptions](https://learn.microsoft.com/en-us/dotnet/api/microsoft.sqlserver.management.smo.scriptingoptions?view=sql-smo-160)