Rsync (SSH) โ
Store backups on any remote server using rsync's efficient delta-transfer algorithm over SSH.
Overview โ
Rsync is a fast, versatile file synchronization tool that uses SSH for secure transfer. Benefits:
- โก Delta transfers โ only changed blocks are sent
- ๐ Encrypted transfer (SSH)
- ๐๏ธ Built-in transfer compression
- ๐ฅ๏ธ Works with any Linux/macOS server
- ๐ Multiple authentication methods (Password, SSH Key, SSH Agent)
- โ๏ธ Customizable with additional rsync flags
Prerequisites โ
System Requirements
The Rsync adapter requires the following CLI tools on the DBackup host:
rsyncโ File synchronization (pre-installed on most systems)openssh-clientโ SSH connectivitysshpassโ Only needed for password authentication
These are pre-installed in the official Docker image. For local development on macOS, see the setup section below.
Configuration โ
| Field | Description | Default |
|---|---|---|
| Name | Friendly name | Required |
| Host | Server hostname or IP | Required |
| Port | SSH port | 22 |
| Username | SSH username | Required |
| Auth Type | Authentication method | password |
| Password | SSH password | Conditional |
| Private Key | SSH key (PEM format) | Conditional |
| Passphrase | Key passphrase | Optional |
| Path Prefix | Remote directory for backups | Required |
| Options | Additional rsync flags | Optional |
Authentication Methods โ
Password Authentication โ
Simplest setup โ requires sshpass on the host:
- Select Auth Type:
password - Enter username and password
Security
Passwords are never passed as command-line arguments. DBackup uses the SSHPASS environment variable exclusively, preventing exposure in process listings.
SSH Key Authentication โ
More secure, recommended for production:
- Select Auth Type:
privateKey - Paste your private key (PEM format)
- Enter passphrase if key is encrypted
Supported key formats:
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAACmFlczI1Ni1jdHI...
-----END OPENSSH PRIVATE KEY----------BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEA...
-----END RSA PRIVATE KEY-----SSH Agent โ
For environments with SSH agent forwarding:
- Select Auth Type:
agent - Mount SSH socket in Docker:
services:
dbackup:
volumes:
- ${SSH_AUTH_SOCK}:/ssh-agent:ro
environment:
- SSH_AUTH_SOCK=/ssh-agentServer Setup โ
Create Backup User โ
# Create user
sudo useradd -m -s /bin/bash backupuser
# Create backup directory
sudo mkdir -p /backups/rsync
sudo chown backupuser:backupuser /backups/rsync
# Set password (if using password auth)
sudo passwd backupuserSSH Key Setup โ
# Generate key pair (on your machine)
ssh-keygen -t ed25519 -f ~/.ssh/dbackup_rsync_key
# Copy public key to server
ssh-copy-id -i ~/.ssh/dbackup_rsync_key.pub backupuser@serverInstall rsync on Target Server โ
Most Linux distributions include rsync, but verify:
# Debian/Ubuntu
sudo apt install rsync
# RHEL/CentOS/Fedora
sudo dnf install rsync
# Alpine
apk add rsyncPath Prefix โ
The Path Prefix defines the base directory on the remote server where all backups are stored. The user must have write permissions to this directory.
Permission Denied
If you see "Permission denied: Cannot create directory", the SSH user does not have write access to the specified path. Use a path within the user's home directory:
- โ
/home/backupuser/backups - โ
~/backups - โ
/backups(requires root or explicit permissions)
Additional Options โ
The Options field allows passing extra rsync flags:
| Option | Description |
|---|---|
--bwlimit=5000 | Limit bandwidth to 5000 KB/s |
--timeout=300 | Set I/O timeout to 300 seconds |
--exclude=*.tmp | Exclude files matching pattern |
--compress-level=9 | Maximum compression level |
Example: --bwlimit=10000 --timeout=600
Directory Structure โ
After backups, your server will have:
/home/backupuser/backups/
โโโ mysql-daily/
โ โโโ backup_2026-02-14T12-00-00.sql.gz
โ โโโ backup_2026-02-14T12-00-00.sql.gz.meta.json
โ โโโ ...
โโโ postgres-weekly/
โโโ ...Docker Configuration โ
The official Docker image includes all required tools. No additional configuration needed:
services:
dbackup:
image: skyfay/dbackup:latest
# rsync, sshpass, openssh-client are pre-installedFor SSH Agent forwarding in Docker:
services:
dbackup:
image: skyfay/dbackup:latest
volumes:
- ${SSH_AUTH_SOCK}:/ssh-agent:ro
environment:
- SSH_AUTH_SOCK=/ssh-agentmacOS Development Setup โ
For local development, install the required tools:
# rsync (macOS ships with an older version)
brew install rsync
# sshpass (only needed for password auth)
brew install hudochenkov/sshpass/sshpassRsync vs SFTP โ
Both use SSH for transfer, but rsync has unique advantages:
| Feature | Rsync | SFTP |
|---|---|---|
| Delta transfers | โ Only changed blocks | โ Full file transfer |
| Transfer compression | โ Built-in | โ Via DBackup only |
| Bandwidth limiting | โ
--bwlimit flag | โ Not supported |
| CLI dependency | โ Required on both ends | โ Uses npm package |
| Custom options | โ Extensive | โ Limited |
| Resume interrupted | โ
--partial flag | โ Restart required |
Use Rsync when: You need efficient incremental transfers, bandwidth control, or are syncing large backup files repeatedly.
Use SFTP when: You want zero CLI dependencies, or the target server doesn't have rsync installed.
Troubleshooting โ
Connection Refused โ
connect ECONNREFUSEDSolutions:
- Verify SSH is running:
systemctl status sshd - Check firewall allows the SSH port
- Verify hostname/IP is correct
Too Many Authentication Failures โ
Too many authentication failuresSolutions:
- Ensure you're using Password auth type (not Agent)
- DBackup automatically disables public key auth for password connections
- Check that SSH agent isn't loaded with many keys
Permission Denied โ
Permission denied: Cannot create directorySolutions:
- Use a path the user owns (e.g.,
/home/user/backups) - Create the directory manually and set ownership:bash
sudo mkdir -p /backups && sudo chown user:user /backups - Check SELinux/AppArmor policies
sshpass Not Found โ
Password authentication requires 'sshpass' to be installedSolutions:
- Use the official Docker image (includes sshpass)
- Install manually:
- Debian/Ubuntu:
sudo apt install sshpass - macOS:
brew install hudochenkov/sshpass/sshpass - Alpine:
apk add sshpass
- Debian/Ubuntu:
- Or switch to SSH Key / Agent authentication
rsync Not Found on Remote โ
rsync: command not foundSolution: Install rsync on the target server:
sudo apt install rsync # Debian/Ubuntu
sudo dnf install rsync # RHEL/Fedora
apk add rsync # AlpineSecurity Best Practices โ
- Use SSH keys instead of passwords
- Disable root login via SSH
- Restrict backup user permissions to the backup directory only
- Use non-standard SSH port (security by obscurity)
- Enable fail2ban for brute-force protection
- Limit bandwidth with
--bwlimitto avoid saturating the network - Firewall rules to limit source IPs
Comparison with Other Destinations โ
| Feature | Rsync | SFTP | S3 | Local |
|---|---|---|---|---|
| Setup complexity | Medium | Medium | Easy | Easiest |
| Self-hosted | โ | โ | โ | โ |
| Delta transfers | โ | โ | โ | N/A |
| Encryption in transit | โ | โ | โ | N/A |
| Bandwidth control | โ | โ | โ | N/A |
| Scalability | Limited | Limited | High | Limited |
| CLI dependency | Yes | No | No | No |
| Cost | Server cost | Server cost | Pay-per-use | Free |