Help › Import, export and back up
Back up and restore a database
Back up a database to a file and restore one, which databases this works for, which programs it uses and where Querlyn finds them.
Querlyn 0.1.0 is not released yet. This help describes it ahead of release.
Querlyn can write a whole database to a file, and put such a file back. How it does that depends on the database.
Which databases
| Database | How | Where the file is |
|---|---|---|
| PostgreSQL | pg_dump and pg_restore, which come with Querlyn | On your computer |
| MySQL | mysqldump and mysql, which you install | On your computer |
| MariaDB | mariadb-dump and mariadb, which you install | On your computer |
| SQLite | SQLite's own backup | On your computer |
| DuckDB | A copy of the database as a DuckDB file | On your computer |
| SQL Server | BACKUP DATABASE and RESTORE DATABASE, run by the server | On the server, at a path you type |
Amazon Redshift, ClickHouse, Oracle Database, Snowflake, BigQuery,
MongoDB, Cassandra, Kafka, Redis and DynamoDB cannot be backed up from Querlyn; for MongoDB, use
mongodump, and for Cassandra nodetool snapshot on each node. These systems keep their backups on the server
side, with their own means. To move data out of them, see
Export results to a file and
Copy tables between connections.
Some databases that speak another engine's protocol cannot be backed up
with that engine's tools, and Querlyn says why when you choose
: pg_dump does not work with
CockroachDB, leaves out YugabyteDB's tablet settings, mysqldump fails on
TiDB, and Azure SQL Database has no BACKUP DATABASE. See
Connect to CockroachDB, TiDB and other compatible databases.
Back up
- Connect, and select the database in the sidebar. For MySQL and MariaDB select the database (shown as a schema), or nothing to back up the connection's own database. Selecting a schema or a table of a PostgreSQL database starts with the backup narrowed to it.
- Choose , or right-click the connection or database and choose Back Up….
- Check the line at the top of the dialog. It names the program that will run, for example "Uses pg_dump 18.6 (bundled with Querlyn)", or says why none can.
- Set the options you need (below), choose Choose… to say where the file goes, and choose Back Up.
Backing up only reads. It never asks for confirmation, and it works on a read-only connection.
The file is written under a temporary name and gets its real name only when the backup succeeded. A failed or cancelled backup leaves no file.
Backup options
| Database | Options |
|---|---|
| PostgreSQL | Format: Custom (pg_restore), a compressed archive, or Plain SQL. Include: Definitions and data, Definitions only or Data only. Objects: Whole database, Chosen schemas or Chosen tables. Leave out owners; leave out privileges. |
| MySQL, MariaDB | Include as above; chosen tables; stored procedures and functions, triggers and scheduled events. The backup is taken as a consistent snapshot without locking tables. |
| SQL Server | Path on server. Copy-only (on at the start, so that the server's own backup schedule is not disturbed); verify checksums; compress. A file already at that path is overwritten. |
| SQLite, DuckDB | None. A DuckDB backup does not include other attached databases. |
Restore
Warning: Restoring writes a backup into a database and can replace what the database holds. On SQLite, DuckDB and SQL Server it replaces the whole database. Check twice which connection and database you are on.
- Connect, and select the database to restore into.
- Choose , or right-click and choose Restore….
- Choose the backup file (for SQL Server, type its path on the server).
- Read the sentence that says what the restore will do and what happens if it fails, then choose Restore….
- Confirm. On Testing, Staging and Production connections you must type the database's name exactly; on Local and Development connections a plain question is asked. The setting that turns confirmations off does not turn this one off.
A read-only connection refuses restores.
What a restore does to what is already there
| Database | What happens to what the database holds |
|---|---|
| PostgreSQL | It stays. The backup's tables and other objects are added, and one that already exists makes the restore fail. With Drop existing objects first, the objects the backup also holds are dropped and created again; what the backup does not hold stays. A restore of data only adds rows to tables that must already exist. |
| PostgreSQL, a plain SQL file | Whatever the file says. A backup made with Drop each object before creating it drops what it then creates; any other file fails on an object that already exists. |
| MySQL, MariaDB | A dump made by Querlyn drops each table it holds and creates it again; a dump of data only adds its rows. Tables the dump does not hold stay. |
| SQLite, DuckDB, SQL Server | Everything is replaced: the database becomes what the backup holds. |
The dialog says which of these applies, for the options you chose, before you start.
What happens if a restore fails
| Database | If it fails or you cancel |
|---|---|
| PostgreSQL | Nothing is changed, as long as All or nothing is on (it is at the start). |
| SQLite, DuckDB | Nothing is changed. |
| MySQL, MariaDB | Not all or nothing. What was restored before the failure stays. |
| SQL Server | The database is left unusable, in the state Restoring, until a restore completes. |
The dialog says which of these applies before you start.
Restore options
| Database | Options |
|---|---|
| PostgreSQL | All or nothing; drop existing objects first; do not restore owners; do not restore privileges. Without dropping first, restoring into a database that already has the backup's tables fails. A plain SQL file is run by Querlyn itself in one transaction; it must be a file written by pg_dump, not compressed. |
| MySQL, MariaDB | None. A dump that switches to another database (made with --databases) is refused before anything runs. |
| SQL Server | Overwrite even if the backup is of another database; disconnect other sessions first. |
While it runs
The dialog shows progress and the program's messages. Hide keeps the run going: the status bar then shows it, and a click there or brings the dialog back. Cancel () stops it.
When it ends, the dialog says how long it took. Copy Messages () copies what the program printed, which is what to send along when you ask for help.
One backup or restore runs at a time. Quitting, or disconnecting its connection, asks whether to cancel it or keep it running.
Where Querlyn finds the programs
For PostgreSQL, Querlyn uses the pg_dump and pg_restore that come with
it. For MySQL and MariaDB, and for a PostgreSQL server newer than the
programs Querlyn brings, it looks on your computer:
- in the folder you set in under Tools,
- on your
PATH, - in the usual places an installer or Homebrew puts them.
Rules:
pg_dumpmust be at least as new as the server.- MySQL servers need MySQL's programs and MariaDB servers need MariaDB's; they are not interchangeable.
Under Tools in Settings, each family shows the program that would be used, its version and where it was found, or why none can be used. Type a folder there to point Querlyn at an installation. Find Tools Again looks again after you installed something ().
Passwords and encryption
- Your password is handed to the backup program privately, not on its command line where other programs could see it. For MySQL and MariaDB it is in a file only you can read, which Querlyn deletes when the run ends.
- The program uses the connection's encryption settings; see Encrypt a connection with TLS.
- A backup through an SSH tunnel or a Kubernetes or SSM tunnel works. Querlyn opens a port on your own computer for the program for as long as the run takes, and lets only that program use it.
Note: For MySQL and MariaDB through a tunnel, the program cannot check that the server's certificate carries the server's name, because it connects to your own computer. If the connection verifies the name, the dialog shows Allow without the host-name check for this run, not ticked, and the run is disabled until you tick it. The rest of the certificate is still checked.
A backup file is not encrypted by Querlyn. Keep it as carefully as the database.
Help for Querlyn 0.1.0. All help topics