gitsql / SQL-Server-Edition

SQL Server Edition
8 stars 2 forks source link

Cron or Task schedule export of schema periodically. #34

Open vg opened 2 years ago

vg commented 2 years ago

Is it possible to schedule a daily export of database schema using task scheduler and automatically commit changes to a git repo?

jamesjburton commented 2 years ago

@vg - yes.

Here's an example on how to create a batch file to perform the export - https://github.com/gitsql/cli-gitsql-sqlserver/blob/master/Export.bat#L1

Execution of the batch file can be scheduled via Task Scheduker.

For automatic commit to git - assuming you've checked out a repository using SSH keys and it's on the branch you wish to commit to - then something like the following can be added to the batch file to automatically commit and push.

cd {repo-path}
git add .
git commit -am "Daily Export"
git push