{"id":13535952,"url":"https://github.com/mittwald/brudi","last_synced_at":"2025-08-04T18:35:02.926Z","repository":{"id":41854010,"uuid":"245348469","full_name":"mittwald/brudi","owner":"mittwald","description":"Easy, incremental and encrypted backup creation / restoration for different backends (file, mongoDB, mysql, postgres, etc.)","archived":false,"fork":false,"pushed_at":"2025-02-17T13:23:06.000Z","size":308,"stargazers_count":65,"open_issues_count":11,"forks_count":8,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-13T13:18:19.026Z","etag":null,"topics":["backups","mongodump","mysqldump","postgresql","restic","s3","tar"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mittwald.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-06T06:43:42.000Z","updated_at":"2025-02-18T11:28:39.000Z","dependencies_parsed_at":"2024-01-17T11:38:22.779Z","dependency_job_id":"bea6d0e2-c6f9-4479-9e18-adfff1282828","html_url":"https://github.com/mittwald/brudi","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mittwald%2Fbrudi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mittwald%2Fbrudi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mittwald%2Fbrudi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mittwald%2Fbrudi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mittwald","download_url":"https://codeload.github.com/mittwald/brudi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245755674,"owners_count":20667027,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backups","mongodump","mysqldump","postgresql","restic","s3","tar"],"created_at":"2024-08-01T09:00:32.583Z","updated_at":"2025-03-27T00:12:57.268Z","avatar_url":"https://github.com/mittwald.png","language":"Go","funding_links":[],"categories":["Other","Go"],"sub_categories":[],"readme":"# brudi\n\nWhen it comes to backup-creation there are several solutions to use.  \nIn general everybody's doing some sort of `dump` or `tar` and backing up the results incremental with [`restic`](https://github.com/restic/restic) or similar programs.\n\nThis is why `brudi` was born. `brudi` supports several backup-methods and is configurable by a simple `yaml` file.\nThe advantage of `brudi` is, that you can create a backup of a source of your choice and save it with `restic` afterwards in one step.\nUnder the hood, `brudi` uses the given binaries like `mysqldump`, `mongodump`, `pg_dump`, `tar` or `restic`.\n\nUsing `brudi` will save you from finding yourself writing bash-scripts to create your backups.\n\nBesides creating backups, `brudi` can also be used to restore your data from backup in an emergency.\n\n## Table of contents\n\n - [Usage](#usage)\n   - [CLI](#cli)\n   - [Docker](#docker)\n   - [Configuration](#configuration)\n      - [Sources](#sources)\n         - [Tar](#tar)\n         - [MySQLDump](#mysqldump)\n         - [MongoDump](#mongodump)\n         - [PgDump](#pgdump)\n            - [Limitations](#limitations)\n         - [Redis](#redis)\n      - [Restic](#restic)\n         - [Forget](#forget)\n      - [Sensitive data: Environment variables](#sensitive-data-environment-variables)\n      - [Gzip support for binaries without native gzip support](#gzip-support-for-binaries-without-native-gzip-support)\n      - [Restoring from backup](#restoring-from-backup)\n         - [TarRestore](#tarrestore)\n         - [MongoRestore](#mongorestore)\n         - [MySQLRestore](#mysqlrestore)\n         - [PgRestore](#pgrestore)\n           - [Restore using pg_restore](#restore-using-pg_restore)\n           - [Restore using psql](#restore-using-psql)\n         - [Restoring using restic](#restoring-using-restic)\n - [Featurestate](#featurestate)\n     - [Source backup methods](#source-backup-methods)\n     - [Restore backup methods](#restore-backup-methods)\n     - [Incremental backup of the source backups](#incremental-backup-of-the-source-backups)\n\n## Usage\n\n### CLI\n\nIn order to use the `brudi`-binary on your local machine or a remote server of your choice, ensure you have the required tools installed.\n\n- `mongodump` (required when running `brudi mongodump`)\n- `mysqldump` (required when running `brudi mysqldump`)\n- `tar` (required when running `brudi tar`)\n- `redis-cli` (required when running `brudi redisdump`)\n- `restic` (required when running `brudi --restic`)\n\n\n```shell\n$ brudi --help\n\nEasy, incremental and encrypted backup creation for different backends (file, mongoDB, mysql, etc.)\nAfter creating your desired tar- or dump-file, brudi backs up the result with restic - if you want to\n\nUsage:\n  brudi [command]\n\nAvailable Commands:\n  help           Help about any command\n  mongodump      Creates a mongodump of your desired server\n  mongorestore   Restores a server from a mongodump\n  mysqldump      Creates a mysqldump of your desired server\n  mysqlrestore   Restores a database from an sqldump\n  pgdump         Creates a pg_dump of your desired postgresql-server\n  pgrestore      Restores a database from a pgdump using pg_restore\n  psql           Restores a database from a plain-text pgdump using psql\n  redisdump      Creates an rdb dump of your desired server\n  tar            Creates a tar archive of your desired \n  tarrestore     Restores files from a tar archive\n  version        Print the version number of brudi\n\nFlags:\n      --cleanup         cleanup backup files afterwards\n  -c, --config string   config file (default is ${HOME}/.brudi.yaml)\n  -h, --help            help for brudi\n      --restic          backup result with 'restic backup'\n      --restic-forget   executes 'restic forget' after backing up things with restic\n      --version         version for brudi\n\nUse \"brudi [command] --help\" for more information about a command.\n```\n\n### Docker\n\nIn case you don't want to install additional tools, you can also use `brudi` inside docker:\n\n`docker run --rm -v ${HOME}/.brudi.yml:/home/brudi/.brudi.yml quay.io/mittwald/brudi mongodump --restic --cleanup`\n\nThe docker-image comes with all required binaries.\n\n### Configuration\n\nAs 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`.\nThe config file itself can include environment-variables via `go-template`:\n\n```yaml\nrestic:\n  global:\n    flags:\n      repo: \"{{ .Env.RESTIC_REPOSITORY }}\"\n```\n\nSince the configuration provided by the `.yaml`-file is mapped to the corresponding CLI-flags, you can adjust literally every parameter of your source backup.  \nTherefore you can simply refer to the official documentation for explanations on the available flags:\n\n- [`restic`](https://restic.readthedocs.io/en/latest/manual_rest.html)\n- [`tar`](https://www.gnu.org/software/tar/manual/html_section/tar_22.html)\n- [`mongodump`](https://docs.mongodb.com/manual/reference/program/mongodump/#options)\n- [`mysqldump`](https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html#mysqldump-option-summary)\n- [`pg_dump`](https://www.postgresql.org/docs/12/app-pgdump.html)\n\nEvery 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`.\nEven though `brudi` should support all cli-flags to be configured via the `.yaml`-file, there may be flags which are not.  \nIn this case, use the `additionalArgs`-key.\n\nIt is also possible to provide more than one configuration file, for example `-c mongodump.yaml -c restic.yaml`. These configs get merged at runtime.\nIf available, the default config will always be laoded first and then overwritten with any values from user-specified files. \nIn case the same config file has been provided more than once, only the first instance will be taken into account.\n\n#### Sources\n\n##### Tar\n\n```yaml\ntar:\n  options:\n    flags:\n      create: true\n      gzip: true\n      file: /tmp/test.tar.gz\n    additionalArgs: []\n    paths:\n      - /tmp/testfile\n  hostName: autoGeneratedIfEmpty\n```\n\nRunning: `brudi tar -c ${HOME}/.brudi.yml --cleanup`\n\nBecomes the following command:  \n`tar -c -z -f /tmp/test.tar.gz /tmp/testfile`  \n\nAll available flags to be set in the `.yaml`-configuration can be found [here](pkg/source/tar/cli.go#L7).\n\n##### MySQLDump\n\n```yaml\nmysqldump:\n  options:\n    flags:\n      host: 127.0.0.1\n      port: 3306\n      password: mysqlroot\n      user: root\n      opt: true\n      allDatabases: true\n      resultFile: /tmp/test.sqldump\n    additionalArgs: []\n```\n\nRunning: `brudi mysqldump -c ${HOME}/.brudi.yml --cleanup`\n\nBecomes the following command:  \n`mysqldump --all-databases --host=127.0.0.1 --opt --password=mysqlroot --port=3306 --result-file=/tmp/test.sqldump --user=root`  \n\nAll available flags to be set in the `.yaml`-configuration can be found [here](pkg/source/mysqldump/cli.go#L7).\n\n##### MongoDump\n\n```yaml\nmongodump:\n  options:\n    flags:\n      host: 127.0.0.1\n      port: 27017\n      username: root\n      password: mongodbroot\n      gzip: true\n      archive: /tmp/dump.tar.gz\n    additionalArgs: []\n```\n\nRunning: `brudi mongodump -c ${HOME}/.brudi.yml --cleanup`\n\nBecomes the following command:  \n`mongodump --host=127.0.0.1 --port=27017 --username=root --password=mongodbroot --gzip --archive=/tmp/dump.tar.gz`  \n\nAll available flags to be set in the `.yaml`-configuration can be found [here](pkg/source/mongodump/cli.go#L7).\n\n##### PgDump\n\n```yaml\npgdump:\n  options:\n    flags:\n      host: 127.0.0.1\n      port: 5432\n      password: postgresroot\n      username: postgresuser\n      dbName: postgres\n      file: /tmp/postgres.dump\n    additionalArgs: []\n```\n\nRunning: `brudi pgdump -c ${HOME}/.brudi.yml --cleanup`\n\nBecomes the following command:  \n`pg_dump --file=/tmp/postgres.dump --dbname=postgres --host=127.0.0.1 --port=5432 --username=postgresuser`  \n\nAll available flags to be set in the `.yaml`-configuration can be found [here](pkg/source/pgdump/cli.go#L7).\n\n###### Limitations\n\nUnfortunately `PostgreSQL` is very strict when it comes to version-compatibility.  \nTherefore your `pg_dump`-binary requires the exact same version your `PostgreSQL`-server is running.\n\nThe Docker-image of `brudi` always has the latest version available for the corresponding alpine-version installed.\n\n##### Redis\n\n```yaml\nredisdump:\n  options:\n    flags:\n      host: 127.0.0.1\n      password: redisdb\n      rdb: /tmp/redisdump.rdb\n    additionalArgs: []\n```\n\nRunning: `brudi redisdump -c ${HOME}/.brudi.yml`\n\nBecomes the following command:\n`redis-cli -h 127.0.0.1 -a redisdb --rdb /tmp/redisdump.rdb bgsave`\n\nAs `redis-cli` is not a dedicated backup tool but a client for `redis`, only a limited number of flags are available by default,\nas you can see [here](pkg/source/redisdump/cli.go#L7).\n\n#### Restic\n\nIn case you're running your backup with the `--restic`-flag, you need to provide a [valid configuration for restic](https://restic.readthedocs.io/en/latest/030_preparing_a_new_repo.html).  \nYou can either configure `restic` via `brudi`s `.yaml`-configuration, or via the [environment variables](https://restic.readthedocs.io/en/latest/040_backup.html#environment-variables) used by `restic`.  \n\nIf you're already using `restic` in your environment, you should have everything set up perfectly to use `brudi` with `--restic`.\n\n##### Forget\n\nIt's also possible to run `restic forget`-cmd after executing `restic backup` with `brudi` by using `--restic-forget`.  \nThe `forget`-policy is defined in the configuration `.yaml` for brudi.\n\nExample `.yaml`-configuration:\n\n```yaml\nrestic:\n    global:\n      flags:\n        # you can provide the repository also via RESTIC_REPOSITORY\n        repo: \"s3:s3.eu-central-1.amazonaws.com/your.s3.bucket/myResticRepo\"\n    backup:\n      flags:\n        # in case there is no hostname given, the hostname from source backup is used\n        hostname: \"MyHost\"\n      # these paths are backuped additionally to your given source backup\n      paths: []\n  forget:\n    flags:\n      keepLast: 48\n      keepHourly: 24\n      keepDaily: 7\n      keepWeekly: 2\n      keepMonthly: 6\n      keepYearly: 2\n    ids: []\n```\n\n#### Sensitive data: Environment variables\n\nIn case you don't want to provide data directly in the `.yaml`-file, e.g. sensitive data like passwords, you can use environment-variables.\nEach key of the configuration is overwritable via environment-variables. Your variable must specify the whole path to a key, seperated by `_`.  \nFor example, given this `.yaml`:\n\n```yaml\nmongodump:\n  options:\n    flags:\n      username: \"\" # we will override this by env\n      password: \"\" # we will override this by env\n      host: 127.0.0.1\n      port: 27017\n      gzip: true\n      archive: /tmp/dump.tar.gz\n```\n\nSet your env's:\n\n```shell\nexport MONGODUMP_OPTIONS_FLAGS_USERNAME=\"root\"\nexport MONGODUMP_OPTIONS_FLAGS_PASSWORD=\"mongodbroot\"\n```\n\nAs 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.\n\n#### Gzip support for binaries without native gzip support\n\nThe tools `mysqldump`, `pg_dump` and `redis-cli` don't natively support `gzip`. However, if the desired path for the backup file is suffixed with `.gz`,\nbrudi will automatically `gzip` the backup after creation and delete the uncompressed backup file. For restoration, the file will be automatically\nuncompressed. Example for mysql:\n\n```yaml\nmysqldump:\n  options:\n    flags:\n      host: 127.0.0.1\n      port: 3306\n      password: mysqlroot\n      user: root\n      opt: true\n      allDatabases: true\n      resultFile: /tmp/test.sqldump.gz\n    additionalArgs: []\n```\n\n```yaml\nmysqlrestore:\n  options:\n    flags:\n      host: 127.0.0.1\n      port: 3306\n      password: mysqlroot\n      user: root\n      Database: test\n    additionalArgs: []\n    sourceFile: /tmp/test.sqldump.gz\n```\n\n\n#### Restoring from backup\n\n##### TarRestore\n\n```yaml\ntarrestore:\n  options:\n    flags:\n      extract: true\n      gzip: true\n      file: /tmp/test.tar.gz\n      target: \"/\"\n    additionalArgs: []\n  hostName: autoGeneratedIfEmpty\n```\n\nRunning: `brudi tarrestore -c ${HOME}/.brudi.yml`\n\nBecomes the following command:\n`tar -x -z -f /tmp/test.tar.gz -C /`   \n\n##### MongoRestore\n\n ```yaml\n mongorestore:\n   options:\n     flags:\n       host: 127.0.0.1\n       port: 27017\n       username: root\n       password: mongodbroot\n       gzip: true\n       archive: /tmp/dump.tar.gz\n     additionalArgs: []\n ```\n \n Running: `brudi mongorestore -c ${HOME}/.brudi.yml `\n \n Becomes the following command:  \n `mongorestore --host=127.0.0.1 --port=27017 --username=root --password=mongodbroot --gzip --archive=/tmp/dump.tar.gz`  \n \n All available flags to be set in the `.yaml`-configuration can be found [here](pkg/source/mongorestore/cli.go#L7).\n\n##### MySQLRestore\n\n```yaml\nmysqlrestore:\n  options:\n    flags:\n      host: 127.0.0.1\n      port: 3306\n      password: mysqlroot\n      user: root\n      Database: test\n    additionalArgs: []\n    sourceFile: /tmp/test.sqldump\n```\n\nRunning: `brudi mysqlrestore -c ${HOME}/.brudi.yml`\n\nBecomes the following command:  \n`mysql --database=test --host=127.0.0.1 --password=mysqlroot --port=3306 --user=root \u003c /tmp/test.sqldump`  \n\nAll available flags to be set in the `.yaml`-configuration can be found [here](pkg/source/mysqlrestore/cli.go#L7).\n\n##### PgRestore\n\nRestoration for PostgreSQL databases is split into two commands, `psql` and `pgrestore`. Which one to use depends on the format of the dump created with `pg_dump`:\n\n`psql` can be used to restore plain-text dumps, which is the default format.\n\n`pgrestore` can be used if the `format` option of `pg_dump` was set to `tar`, `directory` or `custom`.\n\n###### Restore using pg_restore\n\n```yaml\npgrestore:\n  options:\n    flags:\n      host: 127.0.0.1\n      port: 5432\n      username: postgresuser\n      password: postgresroot\n      dbname: postgres\n    additionalArgs: []\n    sourcefile: /tmp/postgres.dump\n```\n\nRunning: `brudi pgrestore -c ${HOME}/.brudi.yml`\n\nBecomes the following command:  \n`pg_restore  --host=127.0.0.1  --port=5432 --username=postgresuser --db-name=postgres /tmp/postgress.dump`  \n\nThis command has to be used if the `format` option was set to `tar`, `directory` or `custom` in `pg_dump`.\n\nAll available flags to be set in the `.yaml`-configuration can be found [here](pkg/source/pgrestore/cli.go#L7).\n\n###### Restore using psql\n\n```yaml\npsql:\n  options:\n    flags:\n      host: 127.0.0.1\n      port: 5432\n      user: postgresuser\n      password: postgresroot\n      dbname: postgres\n    additionalArgs: []\n    sourcefile: /tmp/postgres.dump\n```\n\nRunning: `brudi pgrestore -c ${HOME}/.brudi.yml`\n\nBecomes the following command: \n`psql  --host=127.0.0.1  --port=5432 --user=postgresuser --db-name=postgres \u003c /tmp/postgress.dump`  \n\nThis command has to be used if the `format` option was set to `plain` in `pg_dump`, which is the default.\n\nAll available flags to be set in the `.yaml`-configuration can be found [here](pkg/source/psql/cli.go#L7).\n\n##### Restoring using restic\n\nBackups can be pulled from a `restic` repository and applied to your server by using the `--restic` flag in your brudi command. \nExample configuration for `mongorestore`:\n```yaml\nmongorestore:\n  options:\n    flags:\n      host: 127.0.0.1\n      port: 27017\n      username: root\n      password: mongodbroot\n      gzip: true\n      archive: /tmp/dump.tar.gz\n    additionalArgs: []\nrestic:\n  global:\n    flags:\n      repo: \"s3:s3.eu-central-1.amazonaws.com/your.s3.bucket/myResticRepo\"\n  restore:\n    flags:\n      target: \"/\"\n    id: \"latest\"\n```\n\nThis will pull the latest snapshot of `/tmp/dump.tar.gz` from the repository, which `mongorestore` then uses to restore the server.\nIt is also possible to specify concrete snapshot-ids instead of `latest`.      \n\n## Featurestate\n\n### Source backup methods\n\n- [x] `mysqldump`\n- [x] `mongodump`\n- [x] `tar`\n- [x] `pg_dump`\n- [x] `redisdump`\n\n### Restore backup methods\n\n- [x] `mysqlrestore` \n- [x] `mongorestore`\n- [x] `tarrestore`\n- [x] `pgrestore`\n- [ ]  `redisrestore`\n \n### Incremental backup of the source backups\n\n- [x] `restic`\n  - [x] `commands`\n    - [x] `restic backup`\n    - [x] `restic forget`\n    - [x] `restic restore`\n  - [x] `storage`\n    - [x] `s3`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmittwald%2Fbrudi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmittwald%2Fbrudi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmittwald%2Fbrudi/lists"}