mirror of
https://github.com/jkaninda/mysql-bkup.git
synced 2025-12-08 22:49:41 +01:00
feat: add backup all databases
This commit is contained in:
61
docs/how-tos/backup-all.md
Normal file
61
docs/how-tos/backup-all.md
Normal file
@@ -0,0 +1,61 @@
|
||||
---
|
||||
title: Backup all databases in the server
|
||||
layout: default
|
||||
parent: How Tos
|
||||
nav_order: 12
|
||||
---
|
||||
|
||||
# Backup All Databases
|
||||
|
||||
MySQL-Bkup supports backing up all databases on the server using the `--all-databases` (`-a`) flag. By default, this creates separate backup files for each database. If you prefer a single backup file, you can use the `--all-in-on`e (`-A`) flag.
|
||||
|
||||
Backing up all databases is useful for creating a snapshot of the entire database server, whether for disaster recovery or migration purposes.
|
||||
## Backup Modes
|
||||
|
||||
### Separate Backup Files (Default)
|
||||
|
||||
Using --all-databases without --all-in-one creates individual backup files for each database.
|
||||
|
||||
- Creates separate backup files for each database.
|
||||
- Provides more flexibility in restoring individual databases or tables.
|
||||
- Can be more manageable in cases where different databases have different retention policies.
|
||||
- Might take slightly longer due to multiple file operations.
|
||||
- It is the default behavior when using the `--all-databases` flag.
|
||||
- It does not backup system databases (`information_schema`, `performance_schema`, `mysql`, `sys`, `innodb`).
|
||||
|
||||
**Command:**
|
||||
|
||||
```bash
|
||||
docker run --rm --network your_network_name \
|
||||
-v $PWD/backup:/backup/ \
|
||||
-e "DB_HOST=dbhost" \
|
||||
-e "DB_PORT=3306" \
|
||||
-e "DB_USERNAME=username" \
|
||||
-e "DB_PASSWORD=password" \
|
||||
jkaninda/mysql-bkup backup --all-databases
|
||||
```
|
||||
### Single Backup File
|
||||
|
||||
Using --all-in-one (-A) creates a single backup file containing all databases.
|
||||
|
||||
- Creates a single backup file containing all databases.
|
||||
- Easier to manage if you need to restore everything at once.
|
||||
- Faster to back up and restore in bulk.
|
||||
- Can be problematic if you only need to restore a specific database or table.
|
||||
- It is recommended to use this option for disaster recovery purposes.
|
||||
- It backups system databases as well.
|
||||
|
||||
```bash
|
||||
docker run --rm --network your_network_name \
|
||||
-v $PWD/backup:/backup/ \
|
||||
-e "DB_HOST=dbhost" \
|
||||
-e "DB_PORT=3306" \
|
||||
-e "DB_USERNAME=username" \
|
||||
-e "DB_PASSWORD=password" \
|
||||
jkaninda/mysql-bkup backup --all-in-one
|
||||
```
|
||||
|
||||
### When to Use Which?
|
||||
|
||||
- Use `--all-in-one` if you want a quick, simple backup for disaster recovery where you'll restore everything at once.
|
||||
- Use `--all-databases` if you need granularity in restoring specific databases or tables without affecting others.
|
||||
@@ -34,8 +34,8 @@ Below is an example configuration file (`config.yaml`) that defines multiple dat
|
||||
```yaml
|
||||
# Optional: Define a global cron expression for scheduled backups.
|
||||
# Example: "@every 20m" (runs every 20 minutes). If omitted, backups run immediately.
|
||||
cronExpression: ""
|
||||
|
||||
cronExpression: "" # Optional: Define a global cron expression for scheduled backups.
|
||||
backupRescueMode: false # Optional: Set to true to enable rescue mode for backups.
|
||||
databases:
|
||||
- host: mysql1 # Optional: Overrides DB_HOST or uses DB_HOST_DATABASE1.
|
||||
port: 3306 # Optional: Default is 5432. Overrides DB_PORT or uses DB_PORT_DATABASE1.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
title: Receive notifications
|
||||
layout: default
|
||||
parent: How Tos
|
||||
nav_order: 12
|
||||
nav_order: 13
|
||||
---
|
||||
|
||||
# Receive Notifications
|
||||
|
||||
@@ -6,28 +6,30 @@ nav_order: 3
|
||||
|
||||
# Configuration Reference
|
||||
|
||||
Backup, restore, and migration targets, schedules, and retention policies are configured using **environment variables** or **CLI flags**.
|
||||
|
||||
---
|
||||
MySQL backup, restore, and migration processes can be configured using **environment variables** or **CLI flags**.
|
||||
|
||||
## CLI Utility Usage
|
||||
|
||||
| Option | Short Flag | Description |
|
||||
|-------------------------|------------|-------------------------------------------------------------------------------|
|
||||
| `pg-bkup` | `bkup` | CLI utility for managing PostgreSQL backups. |
|
||||
| `backup` | | Perform a backup operation. |
|
||||
| `restore` | | Perform a restore operation. |
|
||||
| `migrate` | | Migrate a database from one instance to another. |
|
||||
| `--storage` | `-s` | Storage type (`local`, `s3`, `ssh`, etc.). Default: `local`. |
|
||||
| `--file` | `-f` | File name for restoration. |
|
||||
| `--path` | | Path for storage (e.g., `/custom_path` for S3 or `/home/foo/backup` for SSH). |
|
||||
| `--config` | `-c` | Configuration file for multi database backup. (e.g: `/backup/config.yaml`). |
|
||||
| `--dbname` | `-d` | Database name. |
|
||||
| `--port` | `-p` | Database port. Default: `3306`. |
|
||||
| `--disable-compression` | | Disable compression for database backups. |
|
||||
| `--cron-expression` | `-e` | Cron expression for scheduled backups (e.g., `0 0 * * *` or `@daily`). |
|
||||
| `--help` | `-h` | Display help message and exit. |
|
||||
| `--version` | `-V` | Display version information and exit. |
|
||||
The `mysql-bkup` CLI provides commands and options to manage MySQL backups efficiently.
|
||||
|
||||
| Option | Short Flag | Description |
|
||||
|-------------------------|------------|-----------------------------------------------------------------------------------------|
|
||||
| `mysql-bkup` | `bkup` | CLI tool for managing MySQL backups, restoration, and migration. |
|
||||
| `backup` | | Executes a backup operation. |
|
||||
| `restore` | | Restores a database from a backup file. |
|
||||
| `migrate` | | Migrates a database from one instance to another. |
|
||||
| `--storage` | `-s` | Specifies the storage type (`local`, `s3`, `ssh`, etc.). Default: `local`. |
|
||||
| `--file` | `-f` | Defines the backup file name for restoration. |
|
||||
| `--path` | | Sets the storage path (e.g., `/custom_path` for S3 or `/home/foo/backup` for SSH). |
|
||||
| `--config` | `-c` | Provides a configuration file for multi-database backups (e.g., `/backup/config.yaml`). |
|
||||
| `--dbname` | `-d` | Specifies the database name to back up or restore. |
|
||||
| `--port` | `-p` | Defines the database port. Default: `3306`. |
|
||||
| `--disable-compression` | | Disables compression for database backups. |
|
||||
| `--cron-expression` | `-e` | Schedules backups using a cron expression (e.g., `0 0 * * *` or `@daily`). |
|
||||
| `--all-databases` | `-a` | Backs up all databases separately (e.g., `backup --all-databases`). |
|
||||
| `--all-in-one` | `-A` | Backs up all databases in a single file (e.g., `backup --all-databases --single-file`). |
|
||||
| `--help` | `-h` | Displays the help message and exits. |
|
||||
| `--version` | `-V` | Shows version information and exits. |
|
||||
|
||||
---
|
||||
|
||||
@@ -40,6 +42,8 @@ Backup, restore, and migration targets, schedules, and retention policies are co
|
||||
| `DB_NAME` | Optional (if provided via `-d` flag) | Database name. |
|
||||
| `DB_USERNAME` | Required | Database username. |
|
||||
| `DB_PASSWORD` | Required | Database password. |
|
||||
| `DB_SSL_CA` | Optional | Database client CA certificate file |
|
||||
| `DB_SSL_MODE` | Optional(`0 or 1`) default: `0` | Database client Enable CA validation |
|
||||
| `AWS_ACCESS_KEY` | Required for S3 storage | AWS S3 Access Key. |
|
||||
| `AWS_SECRET_KEY` | Required for S3 storage | AWS S3 Secret Key. |
|
||||
| `AWS_BUCKET_NAME` | Required for S3 storage | AWS S3 Bucket Name. |
|
||||
|
||||
Reference in New Issue
Block a user