A modern restic wrapper for database and directory backups with legacy rbackup compatibility.
- Legacy rbackup compatibility: Supports existing YAML configuration files
- Database backups: MySQL, PostgreSQL, MongoDB with native dump tools
- Docker support: Backup from Docker containers and Compose services
- Directory backups: File and folder backup with include/exclude patterns
- Shell commands: Custom backup scripts and commands
- Modern CLI: Built with Cobra for better UX
- Restic integration: Uses restic as the underlying backup system
go install github.com/rs-pro/rsbackup/cmd/rsbackup@latestOr build from source:
git clone https://github.com/rs-pro/rsbackup.git
cd rsbackup
go build -o rsbackup cmd/rsbackup/main.go- Install restic (required dependency):
# Ubuntu/Debian
apt install restic
# macOS
brew install restic
# Or download from https://restic.net/- Initialize a restic repository:
restic init --repo /path/to/backup/repo- Create a backup configuration file (see examples/):
- type: dir
path: /home/user/documents
exclude:
- "*.tmp"
- type: db
activerecord:
adapter: postgresql
database: myapp
username: postgres
password: secret- Run backup:
rsbackup backup --repository /path/to/backup/repo --password mypassword config.ymlrsbackup supports both legacy rbackup format and modern configuration:
- type: dir
path: /data/app
include: ["uploads"]
exclude: [".git", "*.log"]
- type: db
activerecord:
adapter: mysql2
database: myapp
host: localhost
username: user
password: pass
- type: db
env: production
ar_config: /app/config/database.ymljobs:
- type: directory
path: ~/Documents
exclude: ["*.tmp"]
- type: docker
docker:
container_name: mysql_container
exec_command: ["mysqldump", "-u", "root", "mydb"]
- type: compose
compose:
compose_file: ./docker-compose.yml
service_name: database
exec_command: ["pg_dump", "myapp"]- type: dir
path: /path/to/directory
include: # Optional: include only these patterns
- "*.important"
exclude: # Optional: exclude these patterns
- "*.log"
- ".git"
- "regexp:\\.tmp$"- type: db
activerecord:
adapter: mysql2|postgresql
database: dbname
host: localhost
port: 3306
username: user
password: pass
dump_params: ["--single-transaction"] # Optional
- type: db
mongoid:
database: myapp
hosts: ["localhost:27017"]
username: user # Optional
password: pass # Optional
auth_source: admin # Optional- type: db
env: production
ar_config: /app/config/database.yml
- type: db
env: production
mg_config: /app/config/mongoid.yml- type: docker
docker:
container_name: mycontainer
exec_command: ["mysqldump", "-u", "root", "mydb"]
env: # Optional
MYSQL_PWD: secret- type: compose
compose:
compose_file: ./docker-compose.yml
service_name: database
exec_command: ["pg_dump", "-U", "postgres", "mydb"]
env: # Optional
PGPASSWORD: secret- type: shell
shell:
command: tar
args: ["-czf", "-", "/var/log"]
working_dir: /tmp # Optional
env: # Optional
BACKUP_DATE: "2024-01-01"
# Or from config file
- type: shell
env: production
shell_config: /app/config/backup_scripts.yml# Backup with configuration file
rsbackup backup --repository /backup/repo --password secret config.yml
# Use password file instead
rsbackup backup --repository /backup/repo --password-file /path/to/passfile config.yml
# Force full backup (ignore changes)
rsbackup backup --repository /backup/repo --password secret --force config.yml
# Initialize repository
rsbackup init
# Show version
rsbackup version
# Get help
rsbackup helpRESTIC_REPOSITORY: Default repository pathRESTIC_PASSWORD: Default passwordRESTIC_PASSWORD_FILE: Default password fileDB_HOST,DB_USER,DB_PASSWORD: Database connection (can be used in Rails configs)
rsbackup is designed to be a drop-in replacement for rbackup:
- Your existing YAML configuration files should work without changes
- Replace
rbackupcommand withrsbackup - Add
--repositoryand--passwordflags (restic requirements)
- Uses restic instead of custom storage
- Modern CLI with better error messages
- Added Docker and Compose support
- Better validation and error handling
- No built-in server component (use restic REST server)
See the examples/ directory for complete configuration examples:
legacy-config.yml: rbackup compatible configurationmodern-config.yml: Modern format with new featuresdatabase.yml: Rails database configuration examplemongoid.yml: Rails mongoid configuration example
- Go 1.23+
- restic (must be installed and in PATH)
- Database tools:
mysqldump,pg_dump,mongodump(for respective database types) - Docker (for Docker/Compose backups)
MIT License - see LICENSE file for details.