|
| 1 | +# backup containers |
| 2 | + |
| 3 | +This directory contains a collection of containers to help with backing up data. |
| 4 | + |
| 5 | +## Contaienrs |
| 6 | + |
| 7 | +- `quay.io/b-3-n/postgres-backup` - A container that inherits from `postgres:<v>-alpine` and installs a SSH client for remote backups. |
| 8 | +- `quay.io/b-3-n/file-backup` - A container based on `alpine` with an installed SSH client for remote backups. |
| 9 | + |
| 10 | +## Building |
| 11 | + |
| 12 | +Podman/Docker: |
| 13 | + |
| 14 | +```sh |
| 15 | +podman build -t quay.io/b-3-n/<container>:latest -f <contianer>/Containerfile . |
| 16 | +``` |
| 17 | + |
| 18 | +e.g. |
| 19 | + |
| 20 | +```sh |
| 21 | +podman build -t quay.io/b-3-n/file-backup:latest -f file-backup/Containerfile . |
| 22 | +``` |
| 23 | + |
| 24 | +> [!NOTE] |
| 25 | +> The above command is run from this directory, not the container sub-directory. |
| 26 | +
|
| 27 | +## Usage |
| 28 | + |
| 29 | +### `postgres-backup` |
| 30 | + |
| 31 | +Connects to a given Postgres, runs a `pg_dumpall`, throws it into a gzip, and uploads to ssh. |
| 32 | + |
| 33 | +``` |
| 34 | +podman run \ |
| 35 | + --rm \ |
| 36 | + --env SSH_HOST=backup.example.com \ |
| 37 | + quay.io/b-3-n/postgres-backup:latest |
| 38 | +``` |
| 39 | + |
| 40 | +Required ENV vars: |
| 41 | + |
| 42 | +- `SSH_HOST`: SSH hostname for the backup destination |
| 43 | + |
| 44 | +Optional ENV vars: |
| 45 | + |
| 46 | +- `DEBUG`: Extra logs (default: `0`) |
| 47 | +- `DB_HOST`: Hostname of the Postgres database (default: `localhost`) |
| 48 | +- `DB_PORT`: Port of the Postgres database (default: `5432`) |
| 49 | +- `DB_USER`: Username for the Postgres database (default: `postgres`) |
| 50 | +- `DB_PASSWORD`: Password for the Postgres database (default: empty) |
| 51 | +- `SSH_USER`: SSH username for the backup destination (default: `root`) |
| 52 | +- `SSH_PORT`: SSH port for the backup destination (default: `22`) |
| 53 | +- `SSH_REMOTE_DIR`: Directory on the backup destination to store backups (default: `""`) |
| 54 | + |
| 55 | +### `file-backup` |
| 56 | + |
| 57 | +Takes whatever is in $FILE_PATH, tar+gzips it, uploads to ssh. |
| 58 | + |
| 59 | +``` |
| 60 | +podman run \ |
| 61 | + --rm \ |
| 62 | + --env SSH_HOST=backup.example.com \ |
| 63 | + --env FILE_PATH=/data/ \ |
| 64 | + quay.io/b-3-n/file-backup:latest |
| 65 | +``` |
| 66 | + |
| 67 | +Required ENV vars: |
| 68 | + |
| 69 | +- `SSH_HOST`: SSH hostname for the backup destination |
| 70 | +- `FILE_PATH`: The directory to back up |
| 71 | + |
| 72 | +Optional ENV vars: |
| 73 | + |
| 74 | +- `DEBUG`: Extra logs (default: `0`) |
| 75 | +- `DB_HOST`: Hostname of the Postgres database (default: `localhost`) |
| 76 | +- `DB_PORT`: Port of the Postgres database (default: `5432`) |
| 77 | +- `DB_USER`: Username for the Postgres database (default: `postgres`) |
| 78 | +- `DB_PASSWORD`: Password for the Postgres database (default: empty) |
| 79 | +- `SSH_USER`: SSH username for the backup destination (default: `root`) |
| 80 | +- `SSH_PORT`: SSH port for the backup destination (default: `22`) |
| 81 | +- `SSH_REMOTE_DIR`: Directory on the backup destination to store backups (default: `""`) |
0 commit comments