Skip to content
Rowsafe
Docs

CLI reference

Every rowsafe command, its short form, flags, exit codes, environment variables and the .rowsafe.json project file.

The rowsafe CLI talks to the Rowsafe API. Install it and log in as in the Quickstart.

rowsafe help            # the short overview
rowsafe help all        # every command
rowsafe help COMMAND    # one command, e.g. rowsafe help mark
rowsafe version

Flags can come before or after the arguments, with one or two dashes (-yes or --yes).

Database names

Commands that take [NAME] find the database like this:

  1. the NAME argument;
  2. the ROWSAFE_DATABASE environment variable;
  3. "database" in the nearest .rowsafe.json, in this directory or a parent;
  4. your organization's only database, if there is exactly one.

NAME can also be the database's ID. Commands shown with NAME (no brackets) always need it.

Account

CommandWhat it does
rowsafe loginLog in with your browser: confirm the code shown in the terminal. Saves a new API key.
rowsafe login --no-browserPrint the link instead of opening a browser (automatic over SSH).
rowsafe login --key rsk_...Log in with an existing API key (CI, scripts).
rowsafe login --url URLUse another API URL. Default https://api.rowsafe.sh.
rowsafe logoutForget the login and revoke the key rowsafe login created. --keep-key keeps it valid.
rowsafe whoamiThe API URL, organization, plan and API key in use.
rowsafe init [NAME]Write .rowsafe.json here, so commands in this project use NAME.
rowsafe orgPlan, limits and usage.

The login is saved in your config directory (~/.config/rowsafe/config.json on Linux, ~/Library/Application Support/rowsafe/config.json on macOS), readable only by you.

Databases

CommandShort forWhat it does
rowsafe lsdb listYour databases.
rowsafe show [NAME]db showOne database in detail.
rowsafe status [NAME]With a name: is it protected? Without: fleet health. --json for details.
rowsafe adopt NAMEdb adoptRegister an existing PostgreSQL and print a read-only plan.
rowsafe plan [NAME]db planRun the read-only plan again.
rowsafe apply [NAME]db applyApply the plan. Never restarts PostgreSQL.
rowsafe verify [NAME]db verifyProve changes reach your bucket. Activates the schedules and queues the first full backup.

adopt flags:

FlagDefault
--host HOSTHost name or ID. Can be left out when the organization has one host.
--port N5432PostgreSQL's port (names the Unix socket).
--socket-dir DIR/var/run/postgresqlPostgreSQL's Unix socket directory.
--retention-full N2Full backups to keep, 1 to 52.
--no-waitReturn without waiting for the plan.

NAME is 2 to 40 characters: lowercase letters, digits and dashes, starting with a letter.

apply flags: --yes skips the confirmation. --force replaces an existing archive_command or archive_library set by another tool. Only use it if you know what that tool was doing.

Backups, drills and restore points

CommandShort forWhat it does
rowsafe backup [NAME]backup runTake a backup now. --type full (default), diff or incr.
rowsafe backups [NAME]backup listBackups, newest first.
rowsafe drill [NAME]drill runRun a restore drill now.
rowsafe drills [NAME]drill listRestore drills and their results.
rowsafe mark [NAME] [LABEL]Create a restore point. LABEL defaults to manual-<UTC time>.
rowsafe marks [NAME]restore-point listRestore points, with the backup to restore from.
rowsafe tasks [NAME]Recent tasks, for one database or all. --status S, --type T, --limit N (default 30).
rowsafe task show IDOne task with its full log.

Commands that run something wait for it to finish, and exit 1 if it fails. Pass --no-wait to backup, drill and mark to return at once.

With one argument, rowsafe mark X treats X as the database if it names one, and otherwise as the label for the inferred database. So in a project whose .rowsafe.json names app, rowsafe mark before-drop marks app as before-drop.

Database settings

rowsafe db set [NAME] [--retention-full N] [--full-schedule CRON] [--diff-schedule CRON] [--drill-schedule CRON]

Schedules are 5-field cron expressions in UTC, at most once an hour. --diff-schedule "" turns differential backups off. Only the flags you pass change.

rowsafe db set app --retention-full 4 --drill-schedule "0 4 * * 3"
CommandWhat it does
rowsafe db remove NAMEStop managing a database. Never changes the server or the bucket. Once a plan was applied, it needs --keep-archiving, because the server keeps archiving. --yes skips the confirmation.
rowsafe db protection [NAME]Same as rowsafe status NAME.

Monitoring and alerts

CommandWhat it does
rowsafe alertsFiring alerts. --all adds resolved ones, --resolved shows only those.
rowsafe alerts ack IDAcknowledge a firing alert: no more reminders.
rowsafe alerts rulesThe built-in alert rules with your organization's settings.
rowsafe db top NAMETop statements by total time (needs pg_stat_statements). --limit N, at most 20.
rowsafe db activity NAMEQueries running, or idle in a transaction, for over a minute.
rowsafe channels listNotification channels.
rowsafe channels add --type email --name NAME --address A [--address B]Email channel.
rowsafe channels add --type slack|discord|webhook --name NAME --url URLSlack, Discord or webhook channel. A webhook prints its signing secret once.
rowsafe channels remove IDRemove a channel.
rowsafe channels test IDSend a test notification now.

channels add takes --min-severity info|warning|critical (default warning).

Hosts

CommandWhat it does
rowsafe hosts listHosts with agent version and update state.
rowsafe hosts enroll-tokenA one-time token and the install command for a new host. --ttl (default 1h, from 1 minute to 7 days).
rowsafe hosts pin HOST VERSIONKeep a host's agent on VERSION.
rowsafe hosts unpin HOSTFollow the host's update channel again.
rowsafe hosts channel HOST NAMESwitch the host's update channel (e.g. stable, beta).
rowsafe hosts remove HOSTRemove a host without databases and revoke its agent. --yes skips the confirmation.

API keys and audit

CommandWhat it does
rowsafe api-keys listAPI keys.
rowsafe api-keys create NAMECreate a key, shown once. --read-only for a key that can only read.
rowsafe api-keys revoke IDRevoke a key.
rowsafe auditWho changed what, newest first. --limit N (default 50).

AI agents

CommandWhat it does
rowsafe mcpMCP server on stdio, read-only. --allow-restore-points adds restore points; --allow-writes adds every write tool.
rowsafe guardThe Claude Code PreToolUse hook: creates a restore point before a destructive database command. See AI agents.
rowsafe guard --check COMMANDWhether COMMAND looks destructive.

Exit codes

CodeMeaning
0Success. For status: protected, or all healthy. For guard --check: destructive.
1An error, a task that failed, a cancelled confirmation. For guard --check: not destructive.
2rowsafe without arguments. For guard: the command was blocked because protection is required.
3For status and db protection: not protected, or the fleet has warnings or critical problems.

Environment variables

Variable
ROWSAFE_API_KEYAn API key to use instead of the saved login.
ROWSAFE_URLThe API URL to use instead of the saved one. Default https://api.rowsafe.sh.
ROWSAFE_DATABASEThe database for commands where NAME is left out, and for guard.
ROWSAFE_REQUIRE_PROTECTIONFor guard: 1 or true blocks destructive commands when the database isn't protected. Overrides .rowsafe.json.

.rowsafe.json

A project file that names the project's database, for the CLI, the MCP server and the guard hook:

.rowsafe.json
{
  "database": "app",
  "require_protection": false
}
Field
databaseThe database's name in Rowsafe.
require_protectionFor guard only: block destructive commands when the database isn't protected.

rowsafe init app writes it in the current directory, keeping other fields. Commands look for it in the current directory, then each parent. It holds no secrets, so you can commit it.

Edit on GitHub