sjdaws / backup-restore-db

A script to dump and restore MySQL and PostgreSQL databases with Kubernetes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Backup and restore databases

A set of scripts to backup and restore MySQL and PostgreSQL databases.

Usage

These scripts are intended to run as a kubernetes job. Example jobs can be found in the install/kubernetes directory.

Environment variables

The jobs use environment variables to connect to the database.

MySQL backup

Name Description Default
ARGS Additional args to pass to mysqldump
DB_NAMES A comma separated list of databases to backup, if not specified all databases will be backed up*
EXCLUDE_DBS A comma separated list of databases to exclude from backup, ignored if DB_NAMES is set
HISTORY The number of backups to keep, older backups will be removed after a successful backup
HOST Hostname or IP for the MySQL host localhost
PASSWORD Password used to connect to the host
PORT Port the host is listening on 3306
USERNAME Username used to connect to the host

* Backing up all databases will automatically exclude information_schema, mysql, performance_schema, and any database starting with an underscore.

MySQL restore

Name Description Default
ARGS Additional args to pass to mysql
BACKUP_FILE Filename relative to the mounted /backup directory to restore
DB_NAME The name of the database to restore
DROP_FIRST Whether to drop/create the database before restoring false
HOST Hostname or IP for the MySQL host localhost
PASSWORD Password used to connect to the host
PORT Port the host is listening on 3306
USERNAME Username used to connect to the host

PostgreSQL backup

Name Description Default
ARGS Additional args to pass to pg_dump
DB_NAMES A comma separated list of databases to backup, if not specified all databases will be backed up*
EXCLUDE_DBS A comma separated list of databases to exclude from backup, ignored if DB_NAMES is set
HISTORY The number of backups to keep, older backups will be removed after a successful backup
HOST Hostname or IP for the PostgreSQL host localhost
PASSWORD Password used to connect to the host
PORT Port the host is listening on 5432
USERNAME Username used to connect to the host
VERSION The major PostgreSQL version the host is running 15

* Backing up all databases will automatically exclude postgres, template0, template1, and any database starting with an underscore.

PostgreSQL restore

Name Description Default
ARGS Additional args to pass to psql
BACKUP_FILE Filename relative to the mounted /backup directory to restore
DB_NAME The name of the database to restore
DROP_FIRST Whether to drop/create the database before restoring false
HOST Hostname or IP for the PostgreSQL host localhost
PASSWORD Password used to connect to the host
PORT Port the host is listening on 5432
USERNAME Username used to connect to the host
VERSION The major PostgreSQL version the host is running 15

About

A script to dump and restore MySQL and PostgreSQL databases with Kubernetes


Languages

Language:Shell 97.0%Language:Dockerfile 3.0%