docker-mssql-backup
docker-mssql-backup copied to clipboard
Any idea why the backup is not running for me?
I've added the backup to my mssql container but I am having trouble getting the backup to initiate. Here is my docker compose file:
version: "3.3"
services:
server:
environment:
- ACCEPT_EULA=Y
- TZ=America/Toronto
- MSSQL_SA_PASSWORD=xx%xx&2jLr
- MSSQL_PID=Express
- MSSQL_BACKUP_DIR=/var/opt/mssql/backup
- shm-size 1g
ports:
- 1433:1433
volumes:
- /mnt/data/mssql/data:/var/opt/mssql/data
- /mnt/data/mssql/log:/var/opt/mssql/log
- /mnt/data/mssql/secrets:/var/opt/mssql/secrets
- /mnt/data/mssql/backup:/var/opt/mssql/backup
container_name: sqlpreview
hostname: sqlpreview
image: mcr.microsoft.com/mssql/server:2022-preview-ubuntu-22.04
user: root
restart: unless-stopped
backup:
image: bbtsoftwareag/mssql-backup
# for using the cleanup feature, use the backup volume from db.
volumes:
- /mnt/data/mssql/backup:/var/opt/mssql/backup
environment:
- TZ=America/Toronto
- DB_SERVER=sqlpreview
- DB_USER=SA
- DB_PASSWORD=xx%xx&2jLr
- DB_NAMES=school2021_1
- BACKUP_AGE=7
- BACKUP_CLEANUP=true
- PACK=tar
- CRON_SCHEDULE=02 9 27 10 *
networks:
- default
networks: {}
Have I made an error here? Here is some terminal output:
mssql-backup-1 | Starting cron task manager... mssql-backup-1 | - Crontab = 02 9 27 10 * 2024-10-27 09:00:25.75 spid49s [DevOpsSnapshotTelemetryTask] Evaluating the background task. 2024-10-27 09:04:17.15 spid51 XE session 'telemetry_xevents' stopping. 2024-10-27 09:04:17.20 spid51 XE session 'telemetry_xevents' started.
I don't really know how to go about troubleshooting this issue but any advice will be gratefully received.
Hi @myriad007, quick tipp, in markdown you can format code like yaml more beautiful and readable. https://stackoverflow.com/questions/75548339/mixing-yaml-and-markdown
Back to your issue
try to remove following
networks:
- default
networks: {}
or add the default network to the sql container too, and add the default network to the nerworks at bottom e.g.
version: '3.3'
services:
server:
...
networks:
- default
backup:
...
networks:
- default
networks:
default:
for connecting to the database server, DB_SERVER=server (server is the service name) can be used instead of DB_SERVER=sqlpreview
sql preview is an additional dns entry created by hostname: sqlpreview which should not be required, but it depends your final docker-compose.yaml and demands
I added the networks section as shown below. But no joy, still not backing up. Any logs that I should be looking at to help troubleshoot?
version: "3.3" services: mssqlserver: environment: - ACCEPT_EULA=Y - TZ=America/Toronto - MSSQL_SA_PASSWORD=xxx - MSSQL_PID=Express - MSSQL_BACKUP_DIR=/var/opt/mssql/backups - shm-size 1g ports: - 1433:1433 volumes: - /mnt/data/mssql/data:/var/opt/mssql/data - /mnt/data/mssql/log:/var/opt/mssql/log - /mnt/data/mssql/secrets:/var/opt/mssql/secrets - /mnt/data/mssql/backups:/var/opt/mssql/backups container_name: sqlpreview hostname: mssqlserver image: mcr.microsoft.com/mssql/server:2022-preview-ubuntu-22.04 networks: - default user: root restart: unless-stopped backup: image: bbtsoftwareag/mssql-backup # for using the cleanup feature, use the backup volume from db. networks: - default volumes: - /mnt/data/mssql/backups:/var/opt/mssql/backups environment: - TZ=America/Toronto - DB_SERVER=mssqlserver - DB_USER=SA - DB_PASSWORD=xxx - DB_NAMES=school2021_1 - BACKUP_AGE=7 - BACKUP_CLEANUP=true - PACK=tar - CRON_SCHEDULE=3 23 27 10 * networks: default: null
Hi @myriad007
It seems that -MSSQL_BACKUP_DIR=/var/opt/mssql/backups on the sql server container is not working (at least on my Windows machine with Docker Desktop).
The backup is still created on the `/backup' folder inside the container.
I would
# on the sql container remove
- MSSQL_BACKUP_DIR=/var/opt/mssql/backups
# on the sql container change path to
- /mnt/data/mssql/backups:/backup
# on the backup container change to this the backup path as it is the internal cleanup path (https://github.com/bbtsoftware/docker-mssql-backup/blob/bdcc13a3df1ee1776d776f8daa3143e4e3d40d03/backup.sh#L14C1-L15C1)
- /mnt/data/mssql/backups:/backup
# try to set a shorter interval for testing the cron job e.g. every 5 minutes
- CRON_SCHEDULE=*/5 * * * *
to check if both container are running
docker ps
to check the log of a container
docker logs <container id>
to enter a container
docker exec -it <container id> /bin/sh
to exit the container
exit
Tipp: You can use e.g. the first 2 oder 3 characters from the container id - so you don't have to enter the whole id