fdocr / martilla

Easy to configure DB backup tool for simple everyday use on UNIX based systems
https://visualcosita.com/martilla-tool-for-db-backups/
MIT License
10 stars 4 forks source link
backup backup-utility cli database ruby ruby-gem

Martilla

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.

Table of Contents

  1. Installation
  2. Usage
  3. Contributing
  4. License
  5. Code of Conduct

Installation

To use as a CLI tool

$ gem install martilla

Or add this line to your application's Gemfile:

gem 'martilla'

Usage

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:

Databases

Currently available DB types to choose from are postgres & mysql. They both have the same available options:

Storages

The available Storages types are local, S3 & SCP. They each have different available options:

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.

Notifiers

The available Notifiers are ses, sendmail & smtp. They each have different available options:

All of the previous email notifiers also have the following options that can be customized:

Also ALL notifiers have the following two options

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.

Perform a backup

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

Contributing

Check out our contributing guide

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Martilla project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.