Microsoft SQL Server
Configure Microsoft SQL Server databases for backup.
Supported Versions
| Version | Notes |
|---|---|
| SQL Server 2017 | v14.x |
| SQL Server 2019 | v15.x |
| SQL Server 2022 | v16.x |
| Azure SQL Edge | Container-based |
Architecture
Unlike other database adapters that use CLI dump tools, SQL Server backup uses:
- T-SQL
BACKUP DATABASEcommand - Native
.bakformat (full database backup) - File transfer to access
.bakfiles (shared volume or SSH)
This means the backup file is created on the SQL Server first, then transferred to DBackup.
Configuration
Connection Settings
| Field | Description | Default |
|---|---|---|
| Host | SQL Server hostname | localhost |
| Port | SQL Server port | 1433 |
| User | SQL Server login | Required |
| Password | Login password | Required |
| Database | Database name(s) to backup | Required |
Configuration Settings
| Field | Description | Default |
|---|---|---|
| Encrypt | Use encrypted connection | true |
| Trust Server Certificate | Trust self-signed certs | false |
| Request Timeout | Query timeout in ms | 300000 (5 min) |
| Additional Options | Extra BACKUP options | - |
File Transfer Settings
| Field | Description | Default |
|---|---|---|
| Backup Path (Server) | Server-side backup directory | /var/opt/mssql/backup |
| File Transfer Mode | How to access .bak files | local |
| Local Backup Path | Host-side mounted path (local mode) | /tmp |
| SSH Host | SSH host (SSH mode, defaults to DB host) | - |
| SSH Port | SSH port (SSH mode) | 22 |
| SSH Username | SSH username (SSH mode) | - |
| SSH Auth Method | password / privateKey / agent | password |
| SSH Password | SSH password | - |
| SSH Private Key | PEM private key | - |
| SSH Passphrase | Key passphrase | - |
File Transfer Modes
DBackup supports two modes to access the .bak files that SQL Server creates on its filesystem.
Local Mode (Shared Volume)
Use this when DBackup and SQL Server share a filesystem — typically via Docker volume mounts or NFS shares.
services:
dbackup:
volumes:
- ./mssql-backups:/mssql-backups
# Configure in source:
# - Backup Path (Server): /var/opt/mssql/backup
# - File Transfer Mode: local
# - Local Backup Path: /mssql-backups
mssql:
image: mcr.microsoft.com/mssql/server:2022-latest
volumes:
- ./mssql-backups:/var/opt/mssql/backupHow It Works
- DBackup sends
BACKUP DATABASEcommand to SQL Server - SQL Server writes
.bakfile to/var/opt/mssql/backup - DBackup reads the file from
/mssql-backups(same volume) - DBackup processes (compress/encrypt) and uploads to destination
- Cleanup: Original
.bakfile is deleted
SSH Mode (Remote Server)
Use this when SQL Server runs on a remote host (bare-metal, VM, or remote Docker) and there is no shared filesystem. DBackup connects via SSH/SFTP to download/upload .bak files.
Setup
- Set File Transfer Mode to
SSH - Configure SSH credentials (host, username, password or key)
- Set Backup Path (Server) to the directory on the SQL Server host (e.g.,
/var/opt/mssql/backup) - Ensure the SSH user has read/write access to the backup path
SSH Host Default
If SSH Host is left empty, DBackup uses the same hostname as the database connection. This is the most common setup since SSH and SQL Server usually run on the same machine.
How It Works (Backup)
- DBackup sends
BACKUP DATABASEcommand to SQL Server - SQL Server writes
.bakfile to the backup path on its filesystem - DBackup connects via SSH/SFTP and downloads the
.bakfile - DBackup processes (compress/encrypt) and uploads to destination
- Cleanup: Remote
.bakfile is deleted via SSH
How It Works (Restore)
- DBackup downloads the backup from storage
- DBackup connects via SSH/SFTP and uploads the
.bakfile to the backup path - DBackup sends
RESTORE DATABASEcommand to SQL Server - SQL Server reads the
.bakfile from the backup path - Cleanup: Remote
.bakfile is deleted via SSH
SSH Authentication
| Method | Description |
|---|---|
| Password | Simple username/password authentication |
| Private Key | PEM-format private key (optionally with passphrase) |
| Agent | Uses the system SSH agent (SSH_AUTH_SOCK) |
Setting Up a Backup User
Create a dedicated login with backup permissions:
-- Create login
CREATE LOGIN dbackup WITH PASSWORD = 'secure_password_here';
-- Create user in master
USE master;
CREATE USER dbackup FOR LOGIN dbackup;
-- Grant backup permissions
ALTER SERVER ROLE [db_backupoperator] ADD MEMBER dbackup;
-- Or grant on specific databases:
USE mydb;
CREATE USER dbackup FOR LOGIN dbackup;
ALTER ROLE [db_backupoperator] ADD MEMBER dbackup;For restore operations:
ALTER SERVER ROLE [dbcreator] ADD MEMBER dbackup;Backup Process
DBackup executes:
BACKUP DATABASE [MyDatabase]
TO DISK = '/var/opt/mssql/backup/backup_20240115_120000.bak'
WITH FORMAT, INIT, COMPRESSIONBackup Options
Add custom options in "Additional Options":
-- With checksum verification
CHECKSUM
-- With differential backup
DIFFERENTIAL
-- Copy-only (doesn't break log chain)
COPY_ONLY
-- Custom description
DESCRIPTION = 'Daily backup'Connection Security
Encrypted Connection (Recommended)
Enable Encrypt option for production:
- Requires valid SSL certificate on SQL Server
- Or enable Trust Server Certificate for self-signed
Azure SQL
For Azure SQL Database:
- Enable Encrypt
- Keep Trust Server Certificate disabled
- Use Azure AD authentication if needed
Troubleshooting
Connection Timeout
Login failed. The login is from an untrusted domainSolutions:
- Increase Request Timeout for large databases
- Check network latency
- Verify SQL Server is accessible
Backup Permission Denied
Cannot open backup device. Operating system error 5 (Access denied)Solutions:
- SQL Server service account needs write access to backup path
- Check volume mount permissions (local mode) or SSH user file permissions (SSH mode)
- Verify the backup directory exists on the SQL Server
File Not Found After Backup (Local Mode)
Backup completed but file not foundSolutions:
- Verify shared volume is mounted correctly
- Check Backup Path (Server) matches SQL Server mount
- Check Local Backup Path matches DBackup mount
- Verify paths are absolute
SSH Connection Failed (SSH Mode)
SSH connection failed: Authentication failedSolutions:
- Verify SSH credentials (username, password, or key)
- Check that the SSH host and port are correct
- Ensure the SSH service is running on the SQL Server host
- For private key auth, verify the key is in PEM format
- Check firewall rules allow SSH connections (port 22)
SSH File Transfer Failed (SSH Mode)
SFTP download failedSolutions:
- Verify the SSH user has read/write access to the Backup Path (Server)
- Check that the backup directory exists on the server
- Ensure sufficient disk space on the server for
.bakfiles
SSL Certificate Error
The certificate chain was issued by an authority that is not trustedSolutions:
- Enable Trust Server Certificate (development only)
- Install valid SSL certificate on SQL Server
- Add CA certificate to DBackup container
Azure SQL Edge (Docker)
For containerized development:
services:
mssql:
image: mcr.microsoft.com/azure-sql-edge:latest
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=YourStrong@Password123
ports:
- "1433:1433"
volumes:
- ./mssql-backups:/var/opt/mssql/backupConfigure source:
- Host:
mssql(service name) orhost.docker.internal - User:
sa - Encrypt:
false - Trust Server Certificate:
true
Restore
To restore a SQL Server backup:
- Go to Storage Explorer
- Find your
.bakbackup file - Click Restore
- Select target database configuration
- Choose:
- Restore to same database (overwrite)
- Restore to new database name
- Confirm and monitor progress
Restore Process
The restore process depends on the configured File Transfer Mode:
Local mode:
- Copy
.bakfile to shared volume (Local Backup Path) - Execute
RESTORE DATABASEcommand - Verify restore integrity
- Cleanup temporary files
SSH mode:
- Upload
.bakfile to server via SFTP (Backup Path) - Execute
RESTORE DATABASEcommand - Verify restore integrity
- Cleanup: Delete remote
.bakfile via SSH
Best Practices
- Use SSH mode for remote SQL Servers without shared filesystem access
- Use shared volumes with proper permissions for Docker setups
- Enable COMPRESSION in backup options (reduces size 60-80%)
- Use CHECKSUM for integrity verification
- Test restores regularly
- Monitor backup duration and adjust timeout
- Use encrypted connections in production
- Separate backup user from application user
- Enable Trust Server Certificate only in development — use valid certs in production