Easy to configure DB backup tool for simple everyday use on UNIX based systems
Martilla is a tool to automate your backups. With simple but flexible configuration options you can have a database backup configured to run (using cron jobs or similar). Receive a notification whenever a backup fails, choose multiple ways of getting notified (i.e. email + slack).
The name Martilla comes from a local name for the Kinkajou. This nocturnal animal goes fairly unnoticed, just like we hope database backups should remain.
To use as a CLI tool
$ gem install martilla
Or add this line to your application’s Gemfile:
gem 'martilla'
Martilla uses a YAML configuration file that specifies the backup to be performed. The gem works by making three main concepts work together, they’re listed out with details that should generally be specified in the config file:
Execute martilla setup backup-config.yml
and you’ll have your first (default) config file that looks like the following:
---
db:
type: postgres
options:
host: localhost
user: username
password: password
db: databasename
storage:
type: local
options:
filename: database-backup.sql
notifiers:
- type: none
From here on you pick the building blocks that work for your specific case:
Currently available DB types to choose from are postgres & mysql. They both have the same available options:
host
PG_HOST
or MYSQL_HOST
user
PG_USER
or MYSQL_USER
password
PG_PASSWORD
or MYSQL_PASSWORD
db
PG_DATABASE
or MYSQL_DATABASE
port
PG_USER
or MYSQL_USER
The available Storages types are local, S3 & SCP. They each have different available options:
filename
retention
filename
bucket
region
access_key_id
secret_access_key
retention
v0.3.x
added a bug where the s3 storage option might delete other files when enforcing retention. Make sure you’re using v0.4.x
or newer if you want to enforce a retention limit. More details herefilename
host
user
identity_file
retention
All storage types also accept ‘suffix’ as a boolean that enables or disables a timestamp to be added as a suffix to the backup ‘filename’, it defaults as true
.
The available Notifiers are ses, sendmail & smtp. They each have different available options:
aws_region
access_key_id
secret_access_key
address
domain
user_name
password
slack_webhook_url
slack_channel
#general
slack_username
Martilla
All of the previous email notifiers also have the following options that can be customized:
to
from
success_subject
failure_subject
Also ALL notifiers have the following two options
send_success
Boolean
value that will disable notifications on success when set to false. Defaults to true
send_failure
Boolean
value that will disable notifications on failure when set to false. Defaults to true
It’s HIGHLY RECOMMENDED to test and make sure emails are being delivered correctly to each target inbox. Emails with standard messages like these automated backup notifications tend to be easily marked as spam.
As simple as running the backup
command on the martilla CLI and passing as argument the configuration file you want to use
$ martilla backup backup-config.yml
Help the help command help you
$ martilla help
Check out our contributing guide
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the Martilla project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.