Skip to content

"db-vcs-ci" is a tool that automatically backups your database along your code, and inserts the backups to your commits, so you could source-control the backups of your database.

Notifications You must be signed in to change notification settings

taljacob2/db-vcs-ci-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

v0.0.8.9.3.4-beta

db-vcs-ci-client

"db-vcs-ci" is a tool that automatically backups your database along your code, and inserts the backups to your commits, so you could source-control the backups of your database.

The default sql commands that come with "db-vcs-ci" extract / import a MSSQL database that uses SQL Server Management Studio (SSMS) and is run on Windows Server 2012 R2, but you can edit the sql commands to be any commands, for any database.

db-vcs-ci-client-export-db

Installation

Clone This Repository As A Subtree In Your Project

Merge this repository to a new folder called db-vcs-ci-client at the root folder of your project:

git subtree add -P db-vcs-ci-client https://github.com/taljacob2/db-vcs-ci-client master --squash

Configure db-vcs-ci-client

On Windows

Open powershell.exe and run:

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass; db-vcs-ci-client/setup-for-windows.ps1

On Linux

Open terminal and run:

./db-vcs-ci-client/setup-for-linux.sh

Using "db-vcs-ci"

"db-vcs-ci" would backup your database automatically, when you make the git commit command, and will insert the .bak file to your commit.

Export Database

Right after you commit your files via

git commit

"db-vcs-ci" executes a sql command on the server which the database is located on, that:

  1. Exports a backup .bak file of the database.
  2. Downloads it from the server to your actual working-directory.
  3. And finally adds it to your commit.

So the database you are working on will be automatically backed-up to your source-code. The default settings set the .bak file to be placed at db-vcs-ci-client/db-vcs-ci/db.bak. You can change the settings here.

Screenshot Example

image

Skip Exporting A Backup

The backup runs as a "pre-commit" hook. Means, after you run git commit, but before the actual commit process.

In case you don't want to backup the database in your commit, then you can skip the backuping process with:

git commit --no-verify

Backup Database On An Empty Commit

If you want to update the backup of the database on a new commit, and not include changes from source-code, you can call the backup process with an empty commit, like so:

git commit --allow-empty

Import Database (Currently in ALPHA)

Also, "db-vcs-ci" is able to use a backup .bak file you already own, to import it staight into the server's database. This can be done by running:

git import-db

Change Settings

You can change the settings of "db-vcs-ci" in the db-vcs-ci-settings.sh file.

Check For Updates

In case you already have an existing version of "db-vcs-ci-client" and you want to update to the newest version available, you can merge the newest version of this repository to your existing db-vcs-ci-client folder:

git subtree pull -P db-vcs-ci-client https://github.com/taljacob2/db-vcs-ci-client master --squash

FAQ

Export Database

Q:

AFter exporting, I am receiving the following output:

Msg 916, Level 14, State 1, Server WBX-VPS-P42\SQLEXPRESS, Line 1
The server principal "IIS APPPOOL\dbvcsci.example.com" is not able to access the database "KlilDBCore" under the current security context.
Msg 3013, Level 16, State 1, Server WBX-VPS-P42\SQLEXPRESS, Line 1
BACKUP DATABASE is terminating abnormally.

A:

The IIS app that runs the "sqlcmd" command doesn't have credentials for managing the database. You should create a new "SQL Server Authentication" user in your SSMS, so your IIS app could use it to export the database through "sqlcmd".

  1. Follow this video for doing so.
  2. Navigate to db-vcs-ci/export-db/cmd-command-for-windows-server.bat and add the credentials you have made to the "sqlcmd" command, like the following template:
    -U USERNAME -P PASSWORD
    For example:
    del /f %3\%4 >nul 2>&1
    sqlcmd -S %1 -U db-vcs-ci -P pass123456 -Q "BACKUP DATABASE [%2] TO DISK = '%3\%4'"

About

"db-vcs-ci" is a tool that automatically backups your database along your code, and inserts the backups to your commits, so you could source-control the backups of your database.

Resources

Stars

Watchers

Forks

Packages

No packages published