A complete solution for automated backup of Mikrotik devices with S3-compatible storage support.
- Multiple Modes: Support for daemon and cronjob modes
- Parallel Backups: Simultaneous backup execution from multiple routers
- S3 Storage: Support for any S3-compatible storage (Wasabi, AWS S3, etc.)
- Retention Management: Configurable retention policy for daily, monthly, and yearly backups
- Security: Support for existing secrets or inline configuration
- Flexibility: Configuration via values or environment variables
- Kubernetes 1.16+
- Helm 3.0+
- An S3-compatible bucket
- SSH access to Mikrotik routers
- Create the credentials secret:
apiVersion: v1
kind: Secret
metadata:
name: mikrotik-existing-credentials
type: Opaque
stringData:
s3-type: "wasabi"
s3-bucket: "your-bucket"
s3-endpoint: "https://s3.wasabisys.com"
access-key: "your-access-key"
secret-key: "your-secret-key"
username: "backup-user"
ssh-key: |
-----BEGIN OPENSSH PRIVATE KEY-----
your-ssh-private-key
-----END OPENSSH PRIVATE KEY-----
- Install the chart:
helm install mikrotik-backup oci://ghcr.io/thekoma/mikrotik-backup/charts \
-f values-with-existing-secret.yaml
For test or development environments, you can use the all-in-one configuration:
helm install mikrotik-backup oci://ghcr.io/thekoma/mikrotik-backup/charts \
-f values-all-in-one.yaml
- Prepare configuration files:
# Create configuration file
cp config.example.toml config.toml
# Edit file with your parameters
nano config.toml
# Generate SSH key for authentication
ssh-keygen -t ed25519 -f mikrotik-rsa -C "backup@mikrotik"
- Start the container:
docker compose up -d
The service can be configured in two ways:
- Using config.toml (recommended):
services:
mikrotik-backup:
image: ghcr.io/thekoma/mikrotik-backup/app:v2025.06.2
volumes:
- ./config.toml:/etc/mikrotik_backup.toml:ro
- ./mikrotik-rsa:/mikrotik-rsa:ro
environment:
- TZ=Europe/Rome
- Using environment variables:
services:
mikrotik-backup:
image: ghcr.io/thekoma/mikrotik-backup/app:latest
volumes:
- ./mikrotik-rsa:/mikrotik-rsa:ro
environment:
- TZ=Europe/Rome
- MIKROTIK_SSH_USER=backupper
- MIKROTIK_S3_TYPE=wasabi
- MIKROTIK_S3_BUCKET=mikrotik-bck
- MIKROTIK_S3_ENDPOINT=https://s3.wasabisys.com
- MIKROTIK_S3_ACCESS_KEY=your-access-key
- MIKROTIK_S3_SECRET_KEY=your-secret-key
Parameter | Description |
---|---|
volumes |
Mount configuration files and SSH key |
environment |
Configure timezone and configuration overrides |
command |
Customize execution parameters |
restart |
Container restart policy |
Variable | Description | Default |
---|---|---|
MIKROTIK_SSH_USER |
SSH Username | backupper |
MIKROTIK_S3_TYPE |
S3 storage type | wasabi |
MIKROTIK_S3_BUCKET |
Bucket name | - |
MIKROTIK_S3_ENDPOINT |
S3 endpoint | - |
MIKROTIK_S3_ACCESS_KEY |
S3 access key | - |
MIKROTIK_S3_SECRET_KEY |
S3 secret key | - |
TZ |
Timezone | UTC |
deploymentMode: "daemon"
backup:
times: ["02:00", "10:00", "18:00"]
executeOnStart: true
deploymentMode: "cronjob"
backup:
times: ["02:00", "10:00", "18:00"]
storage:
existingSecret: "mikrotik-existing-credentials"
storage:
type: "wasabi"
bucket: "mikrotik-bck"
endpoint: "https://s3.wasabisys.com"
s3Credentials:
accessKey: "your-access-key"
secretKey: "your-secret-key"
ssh:
keyPath: "/mikrotik-rsa"
existingSecret: "mikrotik-existing-credentials"
ssh:
username: "backupper"
keyPath: "/mikrotik-rsa"
key: |
-----BEGIN OPENSSH PRIVATE KEY-----
your-ssh-private-key
-----END OPENSSH PRIVATE KEY-----
retention:
daily: 30 # Keep 30 daily backups
monthly: 12 # Keep 12 monthly backups
yearly: 5 # Keep 5 yearly backups
- Secrets: Always use existing secrets in production
- SSH: Use a dedicated SSH key with minimal permissions
- S3: Create a dedicated IAM user with access only to the required bucket
- Network: Limit network access to only necessary routers
- Create a dedicated group:
/user group add name=backup policy=read,test
- Create a dedicated user:
/user add name=backupper group=backup
- Import SSH key:
/user ssh-keys import public-key-file=mikrotik.pub user=backupper
-
SSH Connection Failed
- Verify SSH key is correct
- Check user permissions on router
- Verify network connectivity
-
S3 Upload Failed
- Verify S3 credentials
- Check bucket permissions
- Verify S3 endpoint
-
Pod Crashes
- Check logs:
kubectl logs -n mikrotik deployment/mikrotik-backup
- Verify configuration in ConfigMap
- Check available resources
- Check logs:
The backup provides detailed logging and statistics:
- Number of completed/failed backups
- Backup sizes
- Execution times
- Retention policy status
Contributions are welcome! Please:
- Fork the repository
- Create a branch for your changes
- Submit a Pull Request
MIT License
For Italian documentation, see README.it_IT.md