bbtsoftware / docker-mssql-backup

Docker image for periodic backups from a Microsoft SQL Server container
MIT License
30 stars 19 forks source link
backup docker mssql

Docker image for backup of Microsoft SQL Server

Docker image to create regular backups of a Microsoft SQL Server image.

Information

Service Stats
Docker Build Pulls Stars Automated
GitHub Last commit Issues PR Size License

General

Topic Description
Image See Docker Hub.
Source See GitHub.

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 Size
0.1.0 Release 0.1.0 Size
0.2.0 Release 0.2.0 Size
0.3.0 Release 0.3.0 Size
0.4.0 Release 0.4.0 Size
0.5.0 Release 0.5.0 Size
0.5.1 Release 0.5.1 Size

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.

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 subdirectory for development or tests with a own readme file.

Discussion

For questions and to discuss ideas & feature requests, use the GitHub discussions on the BBT Software docker-mssql-backup repository.

Join in the discussion on the BBT Software docker-mssql-backup repository

Contributing

Contributions are welcome. See Contribution Guidelines.