An open API service indexing awesome lists of open source software.

https://github.com/jsfraz/mega-backuper

Container for backing up other container's volumes and database dumps to Mega.nz.
https://github.com/jsfraz/mega-backuper

backup container docker docker-volume golang mega mysql-dump

Last synced: about 1 month ago
JSON representation

Container for backing up other container's volumes and database dumps to Mega.nz.

Awesome Lists containing this project

README

          

# mega-backuper

Container for backing up other container's volumes and database dumps to Mega.nz.

## Example usage

> If Mega.nz API returns error 402, login in browser from the same IP address before running the container. ()

This example config backups PostgreSQL database from `postgres-example` container every day at 12:00, and MariaDB database from `mariadb-example` every day at 14:00. It keeps last 10 copies in the output directory, older copies are moved to the rubbish bin.

The `nginx` backup will backup the `nginx-example` container's html directory every day at 10:00.

### Example `backuper.json`

```json
{
"email": "user@example.com",
"password": "12345678",
"backups": [
{
"name": "postgres",
"megaDir": "postgres/",
"lastCopies": 10,
"cron": "0 12 * * *",
"type": "postgres",
"pgUser": "postgres",
"pgPassword": "postgres",
"pgDb": "postgres",
"pgHost": "postgres-example",
"pgPort": 5432
},
{
"name": "nginx",
"megaDir": "nginx/",
"lastCopies": 5,
"cron": "0 10 * * *",
"type": "volume"
},
{
"name": "mariadb",
"megaDir": "mariadb/",
"lastCopies": 10,
"cron": "0 14 * * *",
"type": "mysql",
"mysqlUser": "mariadb",
"mysqlPassword": "mariadb",
"mysqlDb": "mariadb",
"mysqlHost": "mariadb-example",
"mysqlPort": 3306
}
]
}
```

### Example `docker-compose.yaml`

## Export formats

The output files are named using the following pattern: `NAME-UNIX_TIMESTAMP.EXTENSION`.

| Backup Type | Extension | Internal Format |
|-------------|-----------|-------------------------------------------------------------------------|
| `postgres` | `.backup` | Custom PostgreSQL binary format (`pg_dump -Fc`). Compressed internally. |
| `mysql` | `.tar.gz` | Gunzipped tarball containing `.sql` dump. |
| `volume` | `.tar.gz` | Gunzipped tarball containing volume contents. |

## Config file properties

### General properties

| Property | Type | Description | Required |
|----------|---------------------|----------------------------|----------|
| email | string | Your Mega.nz e-mail | true |
| password | string | Your Mega.nz password | true |
| backups | backup object array | Individual backup settings | true |

### Backup object properties

| Property | Type | Description | Required |
|------------------|--------|-------------------------------------------------------|----------|
| name | string | Backup name | true |
| megaDir | string | Remote Mega.nz destination directory | true |
| lastCopies | int | Number of last copies to keep | false |
| cron | string | Cron expression for scheduling backup | true |
| type | string | Backup type (postgres, mysql, volume) | true |

#### PostgreSQL backup properties

> This project uses native `pg_dump` to dump PostgreSQL database, so it supports all of `pg_dump` features like triggers, views, functions, etc.

| Property | Type | Description | Required |
|------------|--------|------------------------------------------------------------------------------------------|----------|
| pgUser | string | PostgreSQL username | true |
| pgPassword | string | PostgreSQL password | true |
| pgDb | string | PostgreSQL database name | true |
| pgHost | string | PostgreSQL host (or container name if running in the same network) | true |
| pgPort | int | PostgreSQL port | true |

#### MySQL/MariaDB backup properties

> This project uses native `mysqldump` to dump MySQL/MariaDB database.

| Property | Type | Description | Required |
|---------------|--------|--------------------------------------------------------------------|----------|
| mysqlUser | string | MySQL username | true |
| mysqlPassword | string | MySQL password | true |
| mysqlDb | string | MySQL database name | true |
| mysqlHost | string | MySQL host (or container name if running in the same network) | true |
| mysqlPort | int | MySQL port | true |

#### Volume backup properties

There are no additional properties for volume backups, however, the `name` property will be used as the directory name mounted to backuper container. Make sure your config looks like this example, where name of the job (`nginx`) is the same as the directory name mounted to backuper container (`/tmp/nginx`).