Skip to content
/ brudi Public
forked from mittwald/brudi

Easy, incremental and encrypted backup creation for different backends (file, mongoDB, mysql, postgres, etc.)

License

Notifications You must be signed in to change notification settings

jkmw/brudi

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

brudi

When it comes to backup-creation there are several solutions to use.
In general everybody's doing some sort of dump or tar and backing up the results incremental with restic or similar programs.

This is why brudi was born. brudi supports several backup-methods and is configurable by a simple yaml file. The advantage of brudi is, that you can create a backup of a source of your choice and save it with restic aftwards in one step. Under the hood, brudi uses the given binaries like mysqldump, mongodump, pg_dump, tar or restic.

Using brudi will save you from finding yourself writing bash-scripts to create your backups.

Table of contents

Usage

CLI

In order to use the brudi-binary on your local machine or a remote server of your choice, ensure you have the required tools installed.

  • mongodump (required when running brudi mongodump)
  • mysqldump (required when running brudi mysqldump)
  • tar (required when running brudi tar)
  • restic (required when running brudi --restic)
$ brudi --help

Easy, incremental and encrypted backup creation for different backends (file, mongoDB, mysql, etc.)
After creating your desired tar- or dump-file, brudi backs up the result with restic - if you want to

Usage:
  brudi [command]

Available Commands:
  help        Help about any command
  mongodump   Creates a mongodump of your desired server
  mysqldump   Creates a mysqldump of your desired server
  pgdump      Creates a pg_dump of your desired postgresql-server
  tar         Creates a tar archive of your desired paths
  version     Print the version number of brudi

Flags:
      --cleanup         cleanup backup files afterwards
  -c, --config string   config file (default is ${HOME}/.brudi.yaml)
  -h, --help            help for brudi
      --restic          backup result with 'restic backup'
      --restic-forget   executes 'restic forget' after backing up things with restic
      --version         version for brudi

Use "brudi [command] --help" for more information about a command.

Docker

In case you don't want to install additional tools, you can also use brudi inside docker:

docker run --rm -v ${HOME}/.brudi.yml:/home/brudi/.brudi.yml quay.io/mittwald/brudi mongodump --restic --cleanup

The docker-image comes with all required binaries.

Configuration

As already mentioned, brudi is configured via .yaml. The default path for this file is ${HOME}/.brudi.yaml, but it's adjustable via -c or --config. The config file itself can include environment-variables via go-template:

restic:
  global:
    flags:
      repo: "{{ .Env.RESTIC_REPOSITORY }}"

Since the configuration provided by the .yaml-file is mapped to the corresponding CLI-flags, you can adjust literally every parameter of your source backup.
Therefore you can simply refer to the official documentation for explanations on the available flags:

Every source has a an additionalArgs-key which's value is an array of strings. The value of this key is appended to the command, generated by brudi. Even though brudi should support all cli-flags to be configured via the .yaml-file, there may be flags which are not.
In this case, use the additionalArgs-key.

Sources

Tar
tar:
  options:
    flags:
      create: true
      gzip: true
      file: /tmp/test.tar.gz
    additionalArgs: []
    paths:
      - /tmp/testfile
  hostName: autoGeneratedIfEmpty

Running: brudi tar -c ${HOME}/.brudi.yml --cleanup

Becomes the following command:
tar -c -z -f /tmp/test.tar.gz /tmp/testfile

All available flags to be set in the .yaml-configuration can be found here.

MySQLDump
mysqldump:
  options:
    flags:
      host: 127.0.0.1
      port: 3306
      password: mysqlroot
      user: root
      opt: true
      allDatabases: true
      resultFile: /tmp/test.sqldump
    additionalArgs: []

Running: brudi mysqldump -c ${HOME}/.brudi.yml --cleanup

Becomes the following command:
mysqldump --all-databases --host=127.0.0.1 --opt --password=mysqlroot --port=3306 --result-file=/tmp/test.sqldump --user=root

All available flags to be set in the .yaml-configuration can be found here.

MongoDump
mongodump:
  options:
    flags:
      host: 127.0.0.1
      port: 27017
      gzip: true
      archive: /tmp/dump.tar.gz
    additionalArgs: []

Running: brudi mongodump -c ${HOME}/.brudi.yml --cleanup

Becomes the following command:
mongodump --host=127.0.0.1 --port=27017 --username=root --password=mongodbroot --gzip --archive=/tmp/dump.tar.gz

All available flags to be set in the .yaml-configuration can be found here.

PgDump
pgdump:
  options:
    flags:
      host: 127.0.0.1
      port: 5432
      password: postgresroot
      username: postgresuser
      dbName: postgres
      file: /tmp/postgres.dump
    additionalArgs: []

Running: brudi pgdump -c ${HOME}/.brudi.yml --cleanup

Becomes the following command:
pg_dump --file=/tmp/postgres.dump --dbname=postgres --host=127.0.0.1 --port=5432 --username=postgresuser

All available flags to be set in the .yaml-configuration can be found here.

Limitations

Unfortunately PostgreSQL is very strict when it comes to version-compatibility.
Therefore your pg_dump-binary requires the exact same version your PostgreSQL-server is running.

The Docker-image of brudi always has the latest version available for the corresponding alpine-version installed.

Restic

In case you're running your backup with the --restic-flag, you need to provide a valid configuration for restic.
You can either configure restic via brudis .yaml-configuration, or via the environment variables used by restic.

If you're already using restic in your environment, you should have everything set up perfectly to use brudi with --restic.

Forget

It's also possible to run restic forget-cmd after executing restic backup with brudi by using --restic-forget.
The forget-policy is defined in the configuration .yaml for brudi.

Example .yaml-configuration:

restic:
    global:
      flags:
        # you can provide the repository also via RESTIC_REPOSITORY
        repo: "s3:s3.eu-central-1.amazonaws.com/your.s3.bucket/myResticRepo"
    backup:
      flags:
        # in case there is no hostname given, the hostname from source backup is used
        hostname: "MyHost"
      # these paths are backuped additionally to your given source backup
      paths: []
  forget:
    flags:
      keepLast: 48
      keepHourly: 24
      keepDaily: 7
      keepWeekly: 2
      keepMonthly: 6
      keepYearly: 2
    ids: []

Sensitive data: Environment variables

In case you don't want to provide data directly in the .yaml-file, e.g. sensitive data like passwords, you can use environment-variables. Each key of the configuration is overwritable via environment-variables. Your variable must specify the whole path to a key, seperated by _.
For example, given this .yaml:

mongodump:
  options:
    flags:
      username: "" # we will override this by env
      password: "" # we will override this by env
      host: 127.0.0.1
      port: 27017
      gzip: true
      archive: /tmp/dump.tar.gz

Set your env's:

export MONGODUMP_OPTIONS_FLAGS_USERNAME="root"
export MONGODUMP_OPTIONS_FLAGS_PASSWORD="mongodbroot"

As soon as a variable for a key exists in your environment, the value of this environment-variable is used in favour of your .yaml-config.

Featurestate

Source backup methods

  • mysqldump
  • mongodump
  • tar
  • pg_dump

Incremental backup of the source backups

  • restic
    • commands
      • restic backup
      • restic forget
    • storage
      • s3

About

Easy, incremental and encrypted backup creation for different backends (file, mongoDB, mysql, postgres, etc.)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 96.6%
  • Makefile 2.3%
  • Dockerfile 1.1%