VPS Snaps
Help/Backup Types/PostgreSQL & MySQL database backups

PostgreSQL & MySQL database backups

How database backups work over SSH, and how to configure them correctly.

5 min readยท๐Ÿ’พ Backup Types

Database backups connect to your server over SSH and run pg_dump (PostgreSQL) or mysqldump (MySQL/MariaDB). The output is compressed with gzip and uploaded to your storage destination.

Supported databases

  • PostgreSQL (pg_dump) โ€” must be installed on the server
  • MySQL (mysqldump) โ€” must be installed on the server
  • MariaDB (mysqldump) โ€” compatible with MySQL tooling

PostgreSQL setup

The SSH user needs permission to run pg_dump. The easiest approach is to add the user to the postgres group, or run as the postgres user itself.

# Allow SSH user to run pg_dump without a password prompt
# In pg_hba.conf, add a trust entry for local connections,
# OR create a .pgpass file for the backup user:
echo "localhost:5432:mydb:myuser:mypassword" > ~/.pgpass
chmod 600 ~/.pgpass

MySQL / MariaDB setup

Create a dedicated backup user with only SELECT and LOCK TABLES permissions:

CREATE USER 'vpssnaps'@'localhost' IDENTIFIED BY 'strong-password';
GRANT SELECT, LOCK TABLES, SHOW VIEW, EVENT, TRIGGER ON *.* TO 'vpssnaps'@'localhost';
FLUSH PRIVILEGES;

Using a minimal-permission backup user is safer than using root. If the credentials were ever exposed, the attacker could only read โ€” not modify โ€” your database.

What gets backed up

By default, VPS Snaps backs up all databases accessible to the configured user. You can specify individual database names in the job config to back up only those.

Backup file format

Files are named with a timestamp and uploaded as .sql.gz to your storage bucket. Example: mydb_2025-06-01T02-00-00Z.sql.gz. You can restore with: gunzip -c file.sql.gz | psql mydb