Administer

Command line

Use Sanad.CLI to run backups, list jobs and connections, read history and chains, restore, and set a local account's password.

Running the tool

The command-line tool is Sanad.CLI.exe in C:\Program Files\Sanad\cli. Setup adds that folder to the system PATH, so Sanad.CLI works in any Command Prompt or PowerShell window opened after the installation. In a window opened before, use the full path.

Run it in a window opened as administrator on the SANAD Backup server: it works directly on SANAD Backup's data in %ProgramData%\Sanad, as the desktop app does.

Sanad.CLI --help
Sanad.CLI backup --help

--help after any command lists its arguments and options. Put names that contain spaces in quotes. Job and connection names are matched without regard to case; usernames and database names must match exactly.

Commands that open SANAD Backup's data first write one line saying whether the tool reached the backup service (version, --help and user set-password do not). Commands always run in the tool's own process, under the account of the command prompt.

Global options

Option Effect
--output, -o table (default), json or csv. json is not available for job list; use -o csv there.
--quiet, -q Hides the command's own output. Errors, the service status line and log lines are still written to the error stream.

Log and status lines go to the error stream, and the list commands give clean -o csv output for pipes and files. The backup and restore commands draw a progress display on standard output unless you add -q, which also hides their result message.

With -o json, connection list prints every stored field of each connection, including its encrypted password. Use -o csv for scripts.

Commands

Command What it does
Sanad.CLI backup run "<job name>" Runs one backup job now and shows its progress.
Sanad.CLI backup run-all Runs every enabled job.
Sanad.CLI job list Lists jobs: ID, name, type, enabled, connection ID, creation date.
Sanad.CLI job enable "<job name>" Enables a job, so its schedules run.
Sanad.CLI job disable "<job name>" Disables a job.
Sanad.CLI connection list Lists connections: ID, name, host, port, authentication, default.
Sanad.CLI connection test "<connection name>" Tests a connection.
Sanad.CLI history Shows recent runs (see below).
Sanad.CLI chain show "<job name>" <database> Shows a database's current backup chain: health, time range and each backup.
Sanad.CLI chain health "<job name>" <database> Reports whether that chain is healthy.
Sanad.CLI restore preview <chain-id> Lists the backups a restore of the chain would apply.
Sanad.CLI restore run <chain-id> ... Restores from a chain (see below).
Sanad.CLI user set-password <username> Sets a local account's password at a hidden prompt.
Sanad.CLI status Its first line says whether the tool reached the backup service; then it shows what runs in its own process. It cannot show backups the service or another app is running.
Sanad.CLI version Shows the tool's version.

Create and edit jobs, schedules and destinations in the app.

Backups

Sanad.CLI backup run "Nightly full"
Sanad.CLI backup run-all

A backup started here runs in the command prompt's process: with Windows Authentication it signs in to SQL Server as you, and it reaches network shares as you. It takes the job's Backup Type; a differential with no usable full backup is taken as a full. The exit code is 0 when the backup succeeded and 1 otherwise; with -q, a partial success also returns 0.

History

Sanad.CLI history --last 50 --job "Nightly full" --status failed
Option Meaning
--last <n> How many recent runs to show. Default 20.
--job <name> Only this job's runs.
--status <status> success, failed (or fail), partial, cancelled or running. Any other value shows runs of every status.

Backup chains

Sanad.CLI chain show "Nightly full" Sales
Sanad.CLI chain health "Nightly full" Sales

Give the database name exactly as SQL Server shows it, including case. chain health exits with 0 when the chain is healthy, 2 when it is not and 1 when the job is not found, so a script can check it. A database with no backups yet, or a misspelt name, also reports Healthy, so check that chain show lists backups.

Restore

Sanad.CLI restore preview 12
Sanad.CLI restore run 12 --target-server 1 --target-db Sales_restored
Sanad.CLI restore run 12 --target-server 1 --target-db Sales_restored --point-in-time 2026-10-19T02:30:00
Option Meaning
<chain-id> The backup chain's numeric ID.
--target-server <id> The ID of the target connection, from connection list. Required: without it the restore stops with "Target connection 0 not found."
--target-db <name> The database to restore into. An existing database with this name is overwritten. Always give it: without it the tool restores into a database named RestoredDb and overwrites any database of that name.
--point-in-time <time> Restore to this moment instead of the latest state. Give a UTC time as yyyy-MM-ddTHH:mm:ss, without Z or an offset.

The tool does not list chain IDs. Unless you already know the ID, use the Restore page, which also asks for a decryption password when the backups need an older one. The exit code is 0 when the restore succeeded and 1 when it did not. See Restore for what the restore checks before it starts.

Set a local account's password

Sanad.CLI user set-password admin

This sets the built-in administrator's password. The last word is the account's username, which is case-sensitive; a new installation has only the built-in administrator account. The command must run in an administrator window, reads the password twice at a hidden prompt and never accepts it as an argument. First sign-in lists its exit codes.