Backup script for a remote MySQL/MariaDB server. Stores each database in a separate directory with a single md5 file for verification.
./mysqlBackup -d /var/backup/mydb -h 192.168.0.1 -u admin -p mypasswordBackup 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.
./postgres_container_backup -d "c:\tmp\db-backup" -h 127.0.0.1 -u devuser -p devpass -P 5432 -n devdb./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_rsaThe backup is stored directly in the backup directory as:
<backup-dir>/<database>_<timestamp>.dump.gz
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.
./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./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- The scripts are designed for a single database workflow, which matches the normal PostgreSQL Docker container setup.
-nis required for both scripts.- Both scripts support optional SSH tunneling when the PostgreSQL service is only reachable through a jump host.
- Successful backup
- Missing parameter
- Directory does not exist or is not writable
- mysqldump is missing or cannot be found in PATH
- Backup directory could not be created
- Success
- Missing required parameter(s)
- Backup directory does not exist or is not writable
- Required command is missing (
pg_dump,gzip, orsshwhen using SSH tunneling) - SSH tunnel could not be established
- Backup failed or the output file could not be created
- Success
- Missing required parameter(s)
- Backup file does not exist or is not readable
- Required command is missing (
pg_restore,psql,gunzip, orsshwhen using SSH tunneling) - SSH tunnel could not be established
- Failed to drop the target database
- Failed to create the target database
- Restore failed