Skip to content

About

Backup of entire mysql.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

11 Commits

Folders and files

Repository files navigation

mysqlBackup

Backup script for a remote MySQL/MariaDB server. Stores each database in a separate directory with a single md5 file for verification.

Example

./mysqlBackup -d /var/backup/mydb -h 192.168.0.1 -u admin -p mypassword

postgres_container_backup

Backup a single PostgreSQL database running in a Docker container (or on a remote PostgreSQL host). The script creates a compressed custom-format dump and wraps it in gzip for smaller file sizes.

Example

./postgres_container_backup -d "c:\tmp\db-backup" -h 127.0.0.1 -u devuser -p devpass -P 5432 -n devdb

Optional SSH tunnel

./postgres_container_backup -d /var/backup/postgres -h 127.0.0.1 -u devuser -p devpass -P 5432 -n devdb -s deploy@10.0.0.1 -i ~/.ssh/id_rsa

The backup is stored directly in the backup directory as:

<backup-dir>/<database>_<timestamp>.dump.gz

postgres_container_restore

Restore a database from a compressed custom dump created by postgres_container_backup. The script terminates active connections to the target database, drops it, recreates it, and restores the dump.

Example

./postgres_container_restore -f "c:\tmp\db-backup\devdb_20261010-201319.dump.gz" -h 127.0.0.1 -u devuser -p devpass -P 5432 -n devdb

Optional SSH tunnel

./postgres_container_restore -f /var/backup/postgres/devdb_20261010-201319.dump.gz -h 127.0.0.1 -u devuser -p devpass -P 5432 -n devdb -s deploy@10.0.0.1 -i ~/.ssh/id_rsa

Notes

  • The scripts are designed for a single database workflow, which matches the normal PostgreSQL Docker container setup.
  • -n is required for both scripts.
  • Both scripts support optional SSH tunneling when the PostgreSQL service is only reachable through a jump host.

Exit codes

mysqlBackup

  1. Successful backup
  2. Missing parameter
  3. Directory does not exist or is not writable
  4. mysqldump is missing or cannot be found in PATH
  5. Backup directory could not be created

postgres_container_backup

  1. Success
  2. Missing required parameter(s)
  3. Backup directory does not exist or is not writable
  4. Required command is missing (pg_dump, gzip, or ssh when using SSH tunneling)
  5. SSH tunnel could not be established
  6. Backup failed or the output file could not be created

postgres_container_restore

  1. Success
  2. Missing required parameter(s)
  3. Backup file does not exist or is not readable
  4. Required command is missing (pg_restore, psql, gunzip, or ssh when using SSH tunneling)
  5. SSH tunnel could not be established
  6. Failed to drop the target database
  7. Failed to create the target database
  8. Restore failed

About

Backup of entire mysql.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages