https://github.com/bbtsoftware/docker-mssql-backup
Docker image for periodic backups from a Microsoft SQL Server container
https://github.com/bbtsoftware/docker-mssql-backup
backup docker mssql
Last synced: 5 months ago
JSON representation
Docker image for periodic backups from a Microsoft SQL Server container
- Host: GitHub
- URL: https://github.com/bbtsoftware/docker-mssql-backup
- Owner: bbtsoftware
- License: mit
- Created: 2020-03-24T12:42:16.000Z (about 6 years ago)
- Default Branch: develop
- Last Pushed: 2024-10-07T08:34:33.000Z (over 1 year ago)
- Last Synced: 2025-05-07T23:07:08.963Z (11 months ago)
- Topics: backup, docker, mssql
- Language: Shell
- Homepage:
- Size: 44.9 KB
- Stars: 35
- Watchers: 7
- Forks: 21
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Docker image for backup of Microsoft SQL Server
Docker image to create regular backups of a [Microsoft SQL Server] image.
## Information
| Service | Stats |
|---------|-------------------------------------------------------------------------------------------|
| Docker | [](https://hub.docker.com/r/bbtsoftwareag/mssql-backup/builds) [](https://hub.docker.com/r/bbtsoftwareag/mssql-backup) [](https://hub.docker.com/r/bbtsoftwareag/mssql-backup) [](https://hub.docker.com/r/bbtsoftwareag/mssql-backup/builds) |
| GitHub | [](https://github.com/bbtsoftware/docker-mssql-backup/commits/master) [](https://github.com/bbtsoftware/docker-mssql-backup/issues) [](https://github.com/bbtsoftware/docker-mssql-backup/pulls) [](https://github.com/bbtsoftware/docker-mssql-backup/) [](https://github.com/bbtsoftware/docker-mssql-backup/blob/master/LICENSE) |
## General
| Topic | Description |
|--------|------------------------------------------------------------------------|
| Image | See [Docker Hub](https://hub.docker.com/r/bbtsoftwareag/mssql-backup). |
| Source | See [GitHub](https://github.com/bbtsoftware/docker-mssql-backup). |
## Usage
This container can create backups on a [Microsoft SQL Server] container.
**NOTE:**
The backup is written to a directory `/backup` inside the [Microsoft SQL Server] container, not to a volume in the backup container.
For using the cleanup feature attach the same `/backup` volume in the `bbtsoftwareag/mssql-backup` container.
### Tags
| Tag | Description | Size |
|--------|-----------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| latest | Latest master build |  |
| 0.1.0 | Release [0.1.0](https://github.com/bbtsoftware/docker-mssql-backup/releases/tag/0.1.0) |  |
| 0.2.0 | Release [0.2.0](https://github.com/bbtsoftware/docker-mssql-backup/releases/tag/0.2.0) |  |
| 0.3.0 | Release [0.3.0](https://github.com/bbtsoftware/docker-mssql-backup/releases/tag/0.3.0) |  |
| 0.4.0 | Release [0.4.0](https://github.com/bbtsoftware/docker-mssql-backup/releases/tag/0.4.0) |  |
| 0.5.0 | Release [0.5.0](https://github.com/bbtsoftware/docker-mssql-backup/releases/tag/0.5.0) |  |
| 0.5.1 | Release [0.5.1](https://github.com/bbtsoftware/docker-mssql-backup/releases/tag/0.5.1) |  |
### Configuration
These environment variables are supported:
| Environment variable | Default value | Description |
|----------------------|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| DB_SERVER | `mssql` | Name or address of the database server to backup. Normally this should be the name of the [Microsoft SQL Server] service. |
| DB_USER | `SA` | User used to connect to the database server. |
| DB_PASSWORD | | Password used to connect to the database server. |
| DB_NAMES | | Names of the databases for which a backup should be created. |
| TZ | | Timezone to use. |
| CRON_SCHEDULE | `0 1 * * sun` | Cron schedule for running backups. NOTE: There is no check if there's already a backup running when starting the backup job. Therefore time interval needs to be longer than the maximum expected backup time for all databases. |
| BACKUP_CLEANUP | `false` | Set to "true" if you want to let the cronjob remove files older than $BACKUP_AGE days |
| BACKUP_AGE | `7` | Number of days to keep backups in backup directory |
| SKIP_BACKUP_LOG | `false` | Skip step to backup the transaction log . |
| PACK | | Possible values: `tar`, `zip`. If defined, compresses the output files into a single `.tar.gz` (or `zip`)-File. |
| ZIP_PASSWORD | | Sets the password for the zip to the given value. Only works if `PACK` is set to `zip` |
| PUSH_REMOTE_MODE | | The possible values `move` or `copy` activates pushing the backup files to a mapped remote directory. The volume `remote` must be mapped. |
| SMTP_HOST | | If this is set, email reporting is enabled by sending the results of the backup process to `MAIL_TO`. You pretty much have to define all the other `SMTP_*` variables, when the host is defined. |
| SMTP_PORT | | The port of the SMTP server |
| SMTP_USER | | The username used to login against the SMTP server |
| SMTP_PASS | | The password for connecting to the SMTP server |
| SMTP_FROM | | The E-mail address from which mails should be sent from |
| SMTP_TLS | `on` | Whether TLS should be used when connecting to the SMTP server |
| MAIL_TO | | The target E-mail address for receiving mail reports |
## Examples
### Docker Compose
The following example will create backups of the databases `MyFirstDatabaseToRestore` and `MySecondDatabaseToRestore`
running inside the `db` container every day at 01.00 CEST and stores it in the `/storage/backup` directory on the host machine.
```yaml
version: '3.7'
services:
db:
image: mcr.microsoft.com/mssql/server
volumes:
- /storage/backup:/backup
environment:
- ACCEPT_EULA=Y
- MSSQL_PID=Express
- SA_PASSWORD=MySecre(12)tPassword
networks:
- default
backup:
image: bbtsoftwareag/mssql-backup
# for using the cleanup feature, use the backup volume from db.
# volumes:
# - /storage/backup:/backup
environment:
- TZ=Europe/Zurich
- DB_SERVER=db
- DB_USER=SA
- DB_PASSWORD=MySecre(12)tPassword
- "DB_NAMES=
MyFirstDatabaseToRestore
MySecondDatabaseToRestore"
- CRON_SCHEDULE=0 1 * * *
networks:
- default
```
### Example environment
We added a small docker environment in the [example](https://github.com/bbtsoftware/docker-mssql-backup/tree/develop/example)
subdirectory for `development` or `tests` with a own [readme](https://github.com/bbtsoftware/docker-mssql-backup/blob/develop/example/README.md) file.
## Discussion
For questions and to discuss ideas & feature requests, use the [GitHub discussions on the BBT Software docker-mssql-backup repository](https://github.com/bbtsoftware/docker-mssql-backup/discussions).
[](https://github.com/bbtsoftware/docker-mssql-backup/discussions)
## Contributing
Contributions are welcome. See [Contribution Guidelines](CONTRIBUTING.md).
[Microsoft SQL Server]: https://hub.docker.com/_/microsoft-mssql-server