diff --git a/cmd/backup.go b/cmd/backup.go index 3eee206..99e3371 100644 --- a/cmd/backup.go +++ b/cmd/backup.go @@ -46,9 +46,10 @@ var BackupCmd = &cobra.Command{ func init() { // Backup - BackupCmd.PersistentFlags().StringP("storage", "s", "local", "Define storage: local, s3, ssh, ftp") - BackupCmd.PersistentFlags().StringP("path", "P", "", "AWS S3 path without file name. eg: /custom_path or ssh remote path `/home/foo/backup`") - BackupCmd.PersistentFlags().StringP("cron-expression", "", "", "Backup cron expression") + BackupCmd.PersistentFlags().StringP("storage", "s", "local", "Define storage: local, s3, ssh, ftp, azure") + BackupCmd.PersistentFlags().StringP("path", "P", "", "Storage path without file name. e.g: /custom_path or ssh remote path `/home/foo/backup`") + BackupCmd.PersistentFlags().StringP("cron-expression", "e", "", "Backup cron expression (e.g., `0 0 * * *` or `@daily`)") + BackupCmd.PersistentFlags().StringP("config", "c", "", "Configuration file for multi database backup. (e.g: `/backup/config.yaml`)") BackupCmd.PersistentFlags().BoolP("disable-compression", "", false, "Disable backup compression") } diff --git a/docs/reference/index.md b/docs/reference/index.md index 8385ef1..07895ca 100644 --- a/docs/reference/index.md +++ b/docs/reference/index.md @@ -21,10 +21,11 @@ Backup, restore, and migration targets, schedules, and retention policies are co | `--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: `5432`. | | `--disable-compression` | | Disable compression for database backups. | -| `--cron-expression` | | Cron expression for scheduled backups (e.g., `* * * * *` or `@daily`). | +| `--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. | @@ -32,47 +33,48 @@ Backup, restore, and migration targets, schedules, and retention policies are co ## Environment Variables -| Name | Requirement | Description | -|--------------------------------|--------------------------------------|-------------------------------------------------------------------------| -| `DB_PORT` | Optional (default: `5432`) | Database port number. | -| `DB_HOST` | Required | Database host. | -| `DB_NAME` | Optional (if provided via `-d` flag) | Database name. | -| `DB_USERNAME` | Required | Database username. | -| `DB_PASSWORD` | Required | Database password. | -| `DB_URL` | Optional | Database URL in JDBC URI format. | -| `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. | -| `AWS_REGION` | Required for S3 storage | AWS Region. | -| `AWS_DISABLE_SSL` | Optional | Disable SSL for S3 storage. | -| `AWS_FORCE_PATH_STYLE` | Optional | Force path-style access for S3 storage. | -| `FILE_NAME` | Optional (if provided via `--file`) | File name for restoration (e.g., `.sql`, `.sql.gz`). | -| `GPG_PASSPHRASE` | Optional | GPG passphrase for encrypting/decrypting backups. | -| `GPG_PUBLIC_KEY` | Optional | GPG public key for encrypting backups (e.g., `/config/public_key.asc`). | -| `BACKUP_CRON_EXPRESSION` | Optional | Cron expression for scheduled backups. | -| `BACKUP_RETENTION_DAYS` | Optional | Delete backups older than the specified number of days. | -| `SSH_HOST` | Required for SSH storage | SSH remote hostname or IP. | -| `SSH_USER` | Required for SSH storage | SSH remote username. | -| `SSH_PASSWORD` | Optional | SSH remote user's password. | -| `SSH_IDENTIFY_FILE` | Optional | SSH remote user's private key. | -| `SSH_PORT` | Optional (default: `22`) | SSH remote server port. | -| `REMOTE_PATH` | Required for SSH/FTP storage | Remote path (e.g., `/home/toto/backup`). | -| `FTP_HOST` | Required for FTP storage | FTP hostname. | -| `FTP_PORT` | Optional (default: `21`) | FTP server port. | -| `FTP_USER` | Required for FTP storage | FTP username. | -| `FTP_PASSWORD` | Required for FTP storage | FTP user password. | -| `TARGET_DB_HOST` | Required for migration | Target database host. | -| `TARGET_DB_PORT` | Optional (default: `5432`) | Target database port. | -| `TARGET_DB_NAME` | Required for migration | Target database name. | -| `TARGET_DB_USERNAME` | Required for migration | Target database username. | -| `TARGET_DB_PASSWORD` | Required for migration | Target database password. | -| `TARGET_DB_URL` | Optional | Target database URL in JDBC URI format. | -| `TG_TOKEN` | Required for Telegram notifications | Telegram token (`BOT-ID:BOT-TOKEN`). | -| `TG_CHAT_ID` | Required for Telegram notifications | Telegram Chat ID. | -| `TZ` | Optional | Time zone for scheduling. | -| `AZURE_STORAGE_CONTAINER_NAME` | Required for Azure Blob Storage | Azure storage container name. | -| `AZURE_STORAGE_ACCOUNT_NAME` | Required for Azure Blob Storage | Azure storage account name. | -| `AZURE_STORAGE_ACCOUNT_KEY` | Required for Azure Blob Storage | Azure storage account key. | +| Name | Requirement | Description | +|--------------------------------|--------------------------------------|----------------------------------------------------------------------------| +| `DB_PORT` | Optional (default: `5432`) | Database port number. | +| `DB_HOST` | Required | Database host. | +| `DB_NAME` | Optional (if provided via `-d` flag) | Database name. | +| `DB_USERNAME` | Required | Database username. | +| `DB_PASSWORD` | Required | Database password. | +| `DB_URL` | Optional | Database URL in JDBC URI format. | +| `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. | +| `AWS_REGION` | Required for S3 storage | AWS Region. | +| `AWS_DISABLE_SSL` | Optional | Disable SSL for S3 storage. | +| `AWS_FORCE_PATH_STYLE` | Optional | Force path-style access for S3 storage. | +| `FILE_NAME` | Optional (if provided via `--file`) | File name for restoration (e.g., `.sql`, `.sql.gz`). | +| `GPG_PASSPHRASE` | Optional | GPG passphrase for encrypting/decrypting backups. | +| `GPG_PUBLIC_KEY` | Optional | GPG public key for encrypting backups (e.g., `/config/public_key.asc`). | +| `BACKUP_CRON_EXPRESSION` | Optional (flag `-e`) | Cron expression for scheduled backups. | +| `BACKUP_RETENTION_DAYS` | Optional | Delete backups older than the specified number of days. | +| `BACKUP_CONFIG_FILE` | Optional (flag `-c`) | Configuration file for multi database backup. (e.g: `/backup/config.yaml`) | +| `SSH_HOST` | Required for SSH storage | SSH remote hostname or IP. | +| `SSH_USER` | Required for SSH storage | SSH remote username. | +| `SSH_PASSWORD` | Optional | SSH remote user's password. | +| `SSH_IDENTIFY_FILE` | Optional | SSH remote user's private key. | +| `SSH_PORT` | Optional (default: `22`) | SSH remote server port. | +| `REMOTE_PATH` | Required for SSH/FTP storage | Remote path (e.g., `/home/toto/backup`). | +| `FTP_HOST` | Required for FTP storage | FTP hostname. | +| `FTP_PORT` | Optional (default: `21`) | FTP server port. | +| `FTP_USER` | Required for FTP storage | FTP username. | +| `FTP_PASSWORD` | Required for FTP storage | FTP user password. | +| `TARGET_DB_HOST` | Required for migration | Target database host. | +| `TARGET_DB_PORT` | Optional (default: `5432`) | Target database port. | +| `TARGET_DB_NAME` | Required for migration | Target database name. | +| `TARGET_DB_USERNAME` | Required for migration | Target database username. | +| `TARGET_DB_PASSWORD` | Required for migration | Target database password. | +| `TARGET_DB_URL` | Optional | Target database URL in JDBC URI format. | +| `TG_TOKEN` | Required for Telegram notifications | Telegram token (`BOT-ID:BOT-TOKEN`). | +| `TG_CHAT_ID` | Required for Telegram notifications | Telegram Chat ID. | +| `TZ` | Optional | Time zone for scheduling. | +| `AZURE_STORAGE_CONTAINER_NAME` | Required for Azure Blob Storage | Azure storage container name. | +| `AZURE_STORAGE_ACCOUNT_NAME` | Required for Azure Blob Storage | Azure storage account name. | +| `AZURE_STORAGE_ACCOUNT_KEY` | Required for Azure Blob Storage | Azure storage account key. | --- diff --git a/pkg/config.go b/pkg/config.go index 31fb1ee..1c6fd48 100644 --- a/pkg/config.go +++ b/pkg/config.go @@ -221,6 +221,7 @@ func initBackupConfig(cmd *cobra.Command) *BackupConfig { utils.SetEnv("STORAGE_PATH", storagePath) utils.GetEnv(cmd, "cron-expression", "BACKUP_CRON_EXPRESSION") utils.GetEnv(cmd, "path", "REMOTE_PATH") + utils.GetEnv(cmd, "config", "BACKUP_CONFIG_FILE") // Get flag value and set env remotePath := utils.GetEnvVariable("REMOTE_PATH", "SSH_REMOTE_PATH") storage = utils.GetEnv(cmd, "storage", "STORAGE")