Skip to content

Back up MySQL and MariaDB databases on a server

Add a database connection, pick one of the four ways WP Safer reaches it, create a backup job and see how every dump is checked.

A server backup can include MySQL and MariaDB databases as well as folders. You add a database connection once on the server’s Databases tab, then create a backup job for it on the Backups tab. Every database is dumped to its own file, so you can download a single database later.

What is included

  • Up to 5 database connections per server, for example one per database server.
  • Up to 3 backup jobs per server, each keeping up to 14 copies. Backups you run by hand count towards the copies too.
  • System databases are skipped. You can back up all databases, only some, or all except some.

Four ways WP Safer reaches the database

Which ways you can pick depends on how the server is connected. Ways that do not fit the server are shown greyed out with the reason.

WayServer connected withHow it works
Agent on the serverthe agentThe agent runs mysqldump on the server and reads the login from a file there. No password is stored in WP Safer.
mysqldump over SSHSSHWP Safer signs in over SSH and runs mysqldump on the server. The password is passed to it through a temporary file, never on the command line.
Direct connection (port 3306)SSH, SFTP or FTPSWP Safer connects to the database from its own address. The database must accept connections from WP Safer on its port (usually closed on shared hosting).
Temporary helper on the siteSFTP or FTPSWP Safer uploads a single-use PHP file to the site folder, calls it over HTTPS to stream the dump and deletes it when the backup ends. For shared hosting where port 3306 is closed.

With the agent: the quickest way

  1. Open the server, go to the Backups tab and press Create backup job.
  2. Under What to back up, choose MySQL / MariaDB, then MySQL / MariaDB on this server (127.0.0.1:3306) as the Database connection.
  3. The agent reads the login from /etc/wpsafer-agent/db.cnf (or /etc/mysql/debian.cnf, or root’s socket login). Passwords never leave your server. If none of these work, create /etc/wpsafer-agent/db.cnf on the server with a [client] section:
    [client]
    user=backup
    password=...
    and make it readable by root only (chmod 600).
  4. Set the schedule and press Create job (see below).

Without the agent: add a database connection

  1. Open the server and go to the Databases tab. Test the server connection first if the tab asks you to.
  2. Press Add a database connection and fill in:
    • Name — for example “Main MySQL”.
    • How WP Safer reaches the database — one of the ways above. It cannot change later; add a new connection instead.
    • Database host and Port. The host is seen from the server itself: 127.0.0.1 or localhost for a database on the same machine.
    • Database user and Password. The password is stored encrypted and sealed and is never shown again; to change it later, type a new one.
    • Which databases — All databases, Only these or All except these, with one name per line.
    • Dump options — a consistent snapshot (--single-transaction, InnoDB), stored procedures and functions, triggers and scheduled events.
  3. For the Temporary helper on the site also fill in the Site address that serves the root folder and tick the box that allows WP Safer to upload the temporary PHP file. The file only reads the database, answers only signed requests and is deleted when the backup ends (or after 6 hours at the latest).
  4. Press Save connection, then Test and list databases. The card shows Connected and the databases it found.

Create the backup job

  1. On the Backups tab press Create backup job and give it a Job name.
  2. Under What to back up choose MySQL / MariaDB and pick the Database connection. Leave Databases (leave empty for all) empty to back up every database of that connection.
  3. Under Schedule, choose Every day, Every week or Only when I run it, and the time. Agent jobs run in the server’s own time zone; jobs without the agent run in your account’s time zone. The form says which one applies.
  4. Under Keep, choose how many copies to keep. When a new backup completes, the oldest one beyond this number is deleted.
  5. Press Create job. To take the first backup straight away, press Run now on the job card.

How each dump is checked

Every database is checked on its own: the dump must end with -- Dump completed and the compressed stream must be complete. A database that fails this check is marked Failed and the run is shown as Partly completed; a partly completed run never deletes older copies. A database that is much smaller than in the previous backup is flagged Much smaller than before, so a table that was emptied by mistake does not go unnoticed.

The Databases tab lists the databases of the last dump with their size and check result, and Download gives you a single database without downloading the whole archive.