Skip to content

Just SqlPackage in a Docker image. It also includes SqlCmd.

License

Notifications You must be signed in to change notification settings

Ark667/SqlPackage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Forks Stargazers Issues MIT License LinkedIn


SqlPackage in a Docker image

Just SqlPackage in a Docker image. It also includes SqlCmd.
Explore the docs »
Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Contributing
  5. License
  6. Contact

About The Project

SqlPackage is a Microsoft tool for importing and exporting bacpac and dacpac files from SQL Server.

This Docker image contains sqlpackage and is designed for when you want to run SqlPackage without installing it locally.

This image also contains sqlcmd. This makes this image very useful for running basic SQL Server tasks.

(back to top)

Built With

(back to top)

Getting Started

Run from current release.

docker run --rm -it ghcr.io/ark667/sqlpackage:master sqlpackage

Build the image locally.

docker build --tag sqlpackage .

(back to top)

Usage

Make a database backup. After execution, the bacpac file will be placed in sqlpackage folder of the current prompt.

docker run --rm -it --network host -v "$($PWD)/sqlpackage:/home" ghcr.io/ark667/sqlpackage:master sqlpackage `
  /Action:Export `
  /SourceServerName:"[host],[port]" `
  /SourceDatabaseName:"[database]" `
  /SourceUser:"[user]" `
  /SourcePassword:"[password]" `
  /TargetFile:"/home/backup.bacpac"

Make a database restore. The imported bacpac must be placed in sqlpackage folder of the current prompt, and database shoud not exists.

docker run --rm -it --network host -v "$($PWD)/sqlpackage:/home" ghcr.io/ark667/sqlpackage:master sqlpackage `
  /Action:Import `
  /TargetServerName:"[host],[port]" `
  /TargetDatabaseName:"[database]" `
  /TargetUser:"[user]" `
  /TargetPassword:"[password]" `
  /SourceFile:"/home/backup.bacpac"

Deploy a database schema. A folder containing the dacpac file is needed.

docker run --rm -it --network host -v "[dacpac_folder]:/home" ghcr.io/ark667/sqlpackage:master sqlpackage `
  /Action:Publish `
  /TargetServerName:"[host],[port]" `
  /TargetDatabaseName:"[database]" `
  /TargetUser:"[user]" `
  /TargetPassword:"[password]" `
  /SourceFile:"/home/[dacpac_file]"

Delete a database. Highly dangerous!

docker run --rm -it --network host ghcr.io/ark667/sqlpackage:master sqlcmd `
  -S "[host],[port]" `
  -U "[user]" `
  -P "[password]" `
  -Q "use [databsae];alter database [database] set single_user with rollback immediate;use master;drop database [database];"

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

ko-fi

(back to top)

Contact

Aingeru Medrano - @AingeruBlack

Project Link: https://github.com/Ark667/SqlPackage

(back to top)

About

Just SqlPackage in a Docker image. It also includes SqlCmd.

Topics

Resources

License

Stars

Watchers

Forks