Copy as CLI command
functionalCopy the sqlly-cli command equivalent to a dump, backup, or export, ready for cron or a runbook.
The export, backup, dump, restore, and scheduled-task dialogs have a
Copy CLI command button. It copies the sqlly-cli command that
does the same job, so you can paste it into cron, a CI step, or a runbook. The command names
the saved connection. The CLI reads the password from the OS keyring the same way the app does,
so the copied line never contains a secret.
sqlly-cli ships inside the app and is usually not on your PATH, so every
copied line starts with the full path of the CLI next to the running app (quoted when the path
has spaces). If the app can't find it, the line starts with plain sqlly-cli.
| Dialog | Copied command |
|---|---|
| Export Database as SQL (built-in) | sqlly-cli dump-database <conn> <db> <output> plus --content, --per-object, --drop-if-exists, --batch-size, --no-views/--no-routines/--no-triggers/--no-sequences, and --schema for each option you changed |
| Export Database as SQL (native) | sqlly-cli dump-database … --native with only the switches the engine's tool honors: --schema, --pg-format, and --include-owner for pg_dump; --no-routines, --no-triggers, and --no-single-transaction for mysqldump |
| Restore from file | sqlly-cli restore-file <conn> <db> <archive> with --clean, --if-exists, --single-transaction, and --no-owner for pg_restore archives, or sqlly-cli run-file … --file <script> for plain SQL |
| Backup / Restore (SQL Server, ClickHouse) | sqlly-cli query <conn> --sql '<BACKUP … / RESTORE …>' --allow-writes --timeout 0. On SQL Server it runs from master. |
| Export Tables | One sqlly-cli query … --sql 'SELECT * FROM …' --format csv --limit 0 --timeout 0 > <file> line per table. It adds | gzip when the export is compressed, and a {date} in the file pattern becomes $(date +%Y%m%d). The button is disabled for formats the CLI can't write. |
| Result export | sqlly-cli query re-running the SELECT that produced the grid, in CSV, TSV, JSON, JSON Lines, or Markdown. The button is disabled when the grid came from a statement that isn't a read-only SELECT, because the CLI runs query read-only. |
| Scheduled task | The command one run performs, with $(date +%Y%m%d-%H%M%S) in place of the scheduler's timestamp. The file name has the same shape the scheduler uses, so the schedule's retention also counts runs made from cron. Query exports become sqlly-cli query … --file <saved query> > <file>. The CLI line does not delete old files. |

What doesn't carry over
- Formats the CLI can't write. XLSX, HTML, XML, SQL INSERT, and code-snippet exports have no CLI equivalent, so the button is disabled for them.
- Client-side views. A result export re-runs the whole query. Grid selections, filters, and sorts only exist in the app.
- App-only export options. The CLI uses its own format defaults: a header row, and CSV cells protected against spreadsheet formulas. Null and line-break settings from the dialog are not passed.
- Production safety. The CLI refuses dumps, restores, and
--allow-writesstatements such as BACKUP on connections marked production. It follows the same rule as the app.
Shell syntax
Copied lines use POSIX shell syntax: single-quoted arguments, > redirects,
| gzip, and $(date …) stamps. They run as-is in bash, zsh, and cron.
On Windows, run them in Git Bash or WSL; Command Prompt and PowerShell quote differently and
are not supported. A value that starts with a hyphen, such as SQL that opens with a
-- comment, is written as --sql='…' so the CLI never mistakes it for an option.
--limit 0 writes every row, and --timeout 0 turns off the 60-second
statement timeout so long exports can finish unattended. CSV, TSV, and JSON Lines output streams
row by row, so a large export doesn't need to fit in memory. Table, JSON, Markdown, and
--json output hold the whole result first.