Sqlcmd
Jump to navigation
Jump to search
backup
sqlcmd -S 10.x.x.x -U sa -P ${PASS} -d master -Q "BACKUP DATABASE demo TO DISK='C:\Temp\demo.bak' WITH COPY_ONLY"
- WITH FORMAT
Backup Restore
List DB Logical Names
RESTORE FILELISTONLY FROM DISK = '/bkp/mydb.bak';
Restore in container
RESTORE DATABASE mydb FROM DISK = '/bkp/file.bak' WITH MOVE 'mydb' TO '/var/opt/mssql/data/mydb.mdf', MOVE 'mydb_log' TO '/var/opt/mssql/data/mydb.ldf', REPLACE; -- Use REPLACE if the database already exists GO
Docker Compose MSSQL
version: '3.2' services: mssql: image: mcr.microsoft.com/mssql/server:2022-latest restart: unless-stopped ports: - "1433:1433" environment: - ACCEPT_EULA=Y - SA_PASSWORD=foobar - TZ=US/Denver - MSSQL_PID=Express volumes: - "./bkp/:/var/opt/mssql/data/" - "./data/:/var/opt/mssql/data/" - "./log/:/var/opt/mssql/log/" - "./secrets/:/var/opt/mssql/secrets/"