Browse articles

Database backup

# Connecting a database to the agent

Add a MySQL/MariaDB, PostgreSQL, or MongoDB connection on the server page, test it, and learn how the password is stored encrypted on your own server.

3 min readUpdated: October 22, 2026[Baca dalam Bahasa Indonesia](/docs/koneksi-database)

A database connection tells the agent which database to back up. Every connection belongs to one server; the agent on that server stores the password and runs the dump.

## 1\. Prepare a database user

Create a dedicated backup user with read access. Example for MySQL/MariaDB (add REPLICATION CLIENT, REPLICATION SLAVE, and RELOAD if you want incremental backups):

```bash
mysql -u root -p -e "CREATE USER 'backup'@'localhost' IDENTIFIED BY '<password>';
GRANT SELECT, SHOW VIEW, TRIGGER, EVENT, RELOAD, REPLICATION CLIENT, REPLICATION SLAVE ON *.* TO 'backup'@'localhost';"
```

For PostgreSQL, the user must be able to read every table in the database being backed up; incremental restores require a superuser. For MongoDB, the built-in `backup` role is enough for dumps and the `restore` role for restores.

## 2\. Add a connection in the dashboard

1.  Open **Servers** and click the target server.
2.  Click **Add database connection**.
3.  Choose the **Engine**: MySQL / MariaDB, PostgreSQL, or MongoDB.
4.  Fill in **Label** (for example _production db_), **Database** (empty = all databases), **Host** (default `localhost`), **Port** (empty = the default 3306, 5432, or 27017), **Username**, and **Password**.
5.  Click **Save & test**.

The password is sent once to the agent over an encrypted channel and stored encrypted (AES-256-GCM) in `/etc/lt-backup` on your server. The control plane does not keep it.

## 3\. Check the test status

The connection status changes from _pending_ to **ready** when the agent connects successfully, or to **error** with the error message. Click **test** to repeat the test at any time. The test is run by the agent, so the server must be online; while the agent is offline, the status stays _pending_.

## 4\. Alternative: add a connection from the server

You can also register a connection directly on the server as root. The agent tests the connection locally before registering it, and the password never passes through the control plane:

```bash
read -rs DB_PASS
printf '%s\n' "$DB_PASS" | lt-backup connection add --engine postgresql --host localhost \
  --user backup --database shop --label "production db" --password-stdin
```

## 5\. Limits and deletion

-   The number of databases per server is limited by your backup plan.
-   Incremental PostgreSQL backups require a connection to one specific database, not all databases.
-   Deleting a connection also deletes the jobs that use it.
-   Connections cannot be edited yet. If the database password changes, delete the connection, add it again, and recreate its jobs.

## Troubleshooting

-   **Error status**: read the message on the server page and see [Connection test failed](/help/uji-koneksi-gagal).
-   **"engine harus mysql, postgresql, atau mongodb"**: choose one of the supported engines.
-   **Database limit message from your plan**: upgrade the plan or delete unused connections.
-   **Status stays pending**: make sure the agent is online on the **Servers** page.

## See also

-   [Installing the agent](/docs/pasang-agent)
-   [Scheduling backups](/docs/jadwal-backup)
-   [MySQL](/docs/backup-mysql), [PostgreSQL](/docs/backup-postgresql), and [MongoDB](/docs/backup-mongodb) backups

Still need help?

Open a support ticket from the dashboard and our team will reply as soon as possible.

[Help center](/en/help)[Open a ticket](/app/support/new)