mirror of
https://github.com/tiredofit/docker-db-backup.git
synced 2025-12-21 21:33:28 +01:00
Merge pull request #165 from eoehen/feature/Improve-mssql-support
Improve MSSQL Support
This commit is contained in:
5
examples/.gitignore
vendored
Normal file
5
examples/.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
||||||
|
|
||||||
|
# Example container mounted folders
|
||||||
|
**/backups/
|
||||||
|
**/db/
|
||||||
61
examples/mssql/docker-compose.yml
Normal file
61
examples/mssql/docker-compose.yml
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
#
|
||||||
|
# Example for Microsoft SQL Server
|
||||||
|
#
|
||||||
|
|
||||||
|
version: '2'
|
||||||
|
|
||||||
|
networks:
|
||||||
|
example-mssql-net:
|
||||||
|
name: example-mssql-net
|
||||||
|
|
||||||
|
services:
|
||||||
|
example-mssql-db:
|
||||||
|
hostname: example-db-host
|
||||||
|
image: mcr.microsoft.com/mssql/server:2019-latest
|
||||||
|
container_name: example-mssql-db
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "127.0.0.1:11433:1433"
|
||||||
|
networks:
|
||||||
|
example-mssql-net:
|
||||||
|
volumes:
|
||||||
|
- ./tmp/backups:/tmp/backups # shared tmp backup directory
|
||||||
|
environment:
|
||||||
|
ACCEPT_EULA: Y
|
||||||
|
MSSQL_SA_PASSWORD: 5hQa0utRFBpIY3yhoIyE
|
||||||
|
MSSQL_PID: Express
|
||||||
|
|
||||||
|
example-mssql-db-backup:
|
||||||
|
container_name: example-mssql-db-backup
|
||||||
|
# if you want to build and use image from current source
|
||||||
|
# execute in terminal --> docker build -t tiredofit/db-backup-mssql .
|
||||||
|
# replace --> image: tiredofit/db-backup-mssql
|
||||||
|
# image: tiredofit/db-backup
|
||||||
|
image: tiredofit/db-backup-mssql
|
||||||
|
links:
|
||||||
|
- example-mssql-db
|
||||||
|
volumes:
|
||||||
|
- ./backups:/backup
|
||||||
|
- ./tmp/backups:/tmp/backups # shared tmp backup directory
|
||||||
|
#- ./post-script.sh:/assets/custom-scripts/post-script.sh
|
||||||
|
environment:
|
||||||
|
# - DEBUG_MODE=TRUE
|
||||||
|
- DB_TYPE=mssql
|
||||||
|
- DB_HOST=example-db-host
|
||||||
|
# - DB_PORT=1488
|
||||||
|
# - DB_NAME=ALL # [ALL] not working on sql server.
|
||||||
|
# create database with name `test1` manually first
|
||||||
|
- DB_NAME=test1
|
||||||
|
- DB_USER=sa
|
||||||
|
- DB_PASS=5hQa0utRFBpIY3yhoIyE
|
||||||
|
- DB_DUMP_FREQ=1 # backup every minute
|
||||||
|
# - DB_DUMP_BEGIN=0000 # backup starts immediately
|
||||||
|
- DB_CLEANUP_TIME=5 # clean backups they are older than 5 minute
|
||||||
|
- ENABLE_CHECKSUM=FALSE
|
||||||
|
- CHECKSUM=SHA1
|
||||||
|
- COMPRESSION=GZ
|
||||||
|
- SPLIT_DB=FALSE
|
||||||
|
- CONTAINER_ENABLE_MONITORING=FALSE
|
||||||
|
restart: always
|
||||||
|
networks:
|
||||||
|
example-mssql-net:
|
||||||
25
examples/docker-compose.yml → examples/mysql/docker-compose.yml
Executable file → Normal file
25
examples/docker-compose.yml → examples/mysql/docker-compose.yml
Executable file → Normal file
@@ -1,9 +1,16 @@
|
|||||||
version: '2'
|
version: '2'
|
||||||
|
|
||||||
|
networks:
|
||||||
|
example-db-network:
|
||||||
|
name: example-db-network
|
||||||
|
|
||||||
services:
|
services:
|
||||||
example-db:
|
example-db:
|
||||||
|
hostname: example-db-host
|
||||||
container_name: example-db
|
container_name: example-db
|
||||||
image: mariadb:latest
|
image: mariadb:latest
|
||||||
|
ports:
|
||||||
|
- 13306:3306
|
||||||
volumes:
|
volumes:
|
||||||
- ./db:/var/lib/mysql
|
- ./db:/var/lib/mysql
|
||||||
environment:
|
environment:
|
||||||
@@ -12,6 +19,8 @@ services:
|
|||||||
- MYSQL_USER=example
|
- MYSQL_USER=example
|
||||||
- MYSQL_PASSWORD=examplepassword
|
- MYSQL_PASSWORD=examplepassword
|
||||||
restart: always
|
restart: always
|
||||||
|
networks:
|
||||||
|
- example-db-network
|
||||||
|
|
||||||
example-db-backup:
|
example-db-backup:
|
||||||
container_name: example-db-backup
|
container_name: example-db-backup
|
||||||
@@ -22,17 +31,21 @@ services:
|
|||||||
- ./backups:/backup
|
- ./backups:/backup
|
||||||
#- ./post-script.sh:/assets/custom-scripts/post-script.sh
|
#- ./post-script.sh:/assets/custom-scripts/post-script.sh
|
||||||
environment:
|
environment:
|
||||||
|
# - DEBUG_MODE=TRUE
|
||||||
- DB_TYPE=mariadb
|
- DB_TYPE=mariadb
|
||||||
- DB_HOST=example-db
|
- DB_HOST=example-db-host
|
||||||
- DB_NAME=example
|
- DB_NAME=example
|
||||||
- DB_USER=example
|
- DB_USER=example
|
||||||
- DB_PASS="examplepassword"
|
- DB_PASS=examplepassword
|
||||||
- DB_DUMP_FREQ=1440
|
- DB_DUMP_FREQ=1 # backup every minute
|
||||||
- DB_DUMP_BEGIN=0000
|
# - DB_DUMP_BEGIN=0000 # backup starts immediately
|
||||||
- DB_CLEANUP_TIME=8640
|
- DB_CLEANUP_TIME=5 # clean backups they are older than 5 minute
|
||||||
- CHECKSUM=SHA1
|
- CHECKSUM=SHA1
|
||||||
- COMPRESSION=ZSTD
|
- COMPRESSION=GZ
|
||||||
- SPLIT_DB=FALSE
|
- SPLIT_DB=FALSE
|
||||||
|
- CONTAINER_ENABLE_MONITORING=FALSE
|
||||||
restart: always
|
restart: always
|
||||||
|
networks:
|
||||||
|
- example-db-network
|
||||||
|
|
||||||
|
|
||||||
0
examples/post-script.sh → examples/mysql/post-script.sh
Executable file → Normal file
0
examples/post-script.sh → examples/mysql/post-script.sh
Executable file → Normal file
@@ -173,7 +173,7 @@ backup_mssql() {
|
|||||||
compression
|
compression
|
||||||
pre_dbbackup "${DB_NAME}"
|
pre_dbbackup "${DB_NAME}"
|
||||||
print_notice "Dumping MSSQL database: '${DB_NAME}'"
|
print_notice "Dumping MSSQL database: '${DB_NAME}'"
|
||||||
/opt/mssql-tools/bin/sqlcmd -E -C -S ${DB_HOST}\,${DB_PORT} -U ${DB_USER} -P ${DB_PASS} –Q "BACKUP DATABASE \[${DB_NAME}\] TO DISK = N'${TEMP_LOCATION}/${target}' WITH NOFORMAT, NOINIT, NAME = '${DB_NAME}-full', SKIP, NOREWIND, NOUNLOAD, STATS = 10"
|
/opt/mssql-tools18/bin/sqlcmd -C -S ${DB_HOST}\,${DB_PORT} -U ${DB_USER} -P ${DB_PASS} -Q "BACKUP DATABASE [${DB_NAME}] TO DISK = N'${TEMP_LOCATION}/${target}' WITH NOFORMAT, NOINIT, NAME = '${DB_NAME}-full', SKIP, NOREWIND, NOUNLOAD, STATS = 10"
|
||||||
exit_code=$?
|
exit_code=$?
|
||||||
check_exit_code $target
|
check_exit_code $target
|
||||||
generate_checksum
|
generate_checksum
|
||||||
|
|||||||
Reference in New Issue
Block a user