snapraid/beta/manual-daemon.html
Andrea Mazzoleni 6d4d44bd92 Auto update
2026-02-24 00:06:55 +01:00

1278 lines
46 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="A backup program for disk arrays. It stores parity information of your data and it recovers from up to six disk failures">
<meta name="keywords" content="snapraid snapshot raid backup disk array redundancy parity">
<title>SnapRAID Daemon Manual</title>
<link rel="stylesheet" href="style.css">
<link rel="apple-touch-icon" sizes="180x180" href="/beta/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/beta/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/beta/favicon-16x16.png">
<link rel="manifest" href="/beta/site.webmanifest">
<script src="script.js"></script>
<!-- Google Analytics 4 -->
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-W1Z5FKHYQ4"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-W1Z5FKHYQ4');
</script>
<!-- Google Universal Analytics -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-21967501-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<header>
<div class="container nav-container">
<a href="index" class="logo">
<img src="android-chrome-192x192.png" width="32" height="32"/>
SnapRAID
</a>
<nav>
<input type="checkbox" id="menu-toggle">
<label for="menu-toggle" class="menu-icon"><svg viewBox="0 0 24 24" width="24" height="24" fill="currentColor"><path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"/></svg></label>
<ul>
<li><a href="index" >Home</a></li>
<li><a href="ui" >UI & Daemon</a></li>
<li><a href="howitworks" >How it Works</a></li>
<li><a href="design" >Design</a></li>
<li><a href="compare" >Compare</a></li>
<li><a href="manual" class="active">Manual</a></li>
<li><a href="faq" >FAQ</a></li>
<li><a href="support" >Support</a></li>
<li><a href="download" class="nav-cta">Download</a></li>
</ul>
</nav>
</div>
</header>
<div class="container manual-layout">
<aside class="manual-sidebar">
<h4>Components</h4>
<select id="manual-selector" style="width: 100%; padding: 5px; background: var(--bg-surface); color: var(--text-primary); border: 1px solid var(--border-color); border-radius: 4px; margin-bottom: 2rem;">
<option value="manual">Command Line</option>
<option value="manual-daemon">Daemon</option>
<option value="manual-log">Log</option>
</select>
<h4>Contents</h4>
<ul id="manual-toc-list">
<!-- Populated by JavaScript -->
</ul>
</aside>
<main id="manual-container">
<div class="manual-doc">
<div class="manual-section-level-1">
<h1 id="sec1" class="manual-title-level-1">
Synopsis
</h1>
<pre>
snapraidd [-c, --conf CONFIG] [-f, --foreground] [-p, --pidfile FILE]
&nbsp;&nbsp;&nbsp;&nbsp;[-N, --no-cache] [-v, --verbose]
</pre>
<pre>
snapraidd [-V, --version] [-H, --help]
</pre>
</div>
<div class="manual-section-level-1">
<h1 id="sec2" class="manual-title-level-1">
Description
</h1>
<p>SnapRAID-Daemon is a specialized companion service designed to move SnapRAID
from a manual, command-line interface (CLI) workflow to an 'always-on'
background service.
</p><p>Under the hood, the daemon uses the same SnapRAID CLI binary, providing the
same level of reliability.
</p><p>The daemon automates critical maintenance tasks, including the scheduling of
sync and scrub operations. It further enhances array reliability by monitoring
SMART values and providing a robust notification engine for real-time health
updates. For energy efficiency, it manages automatic disk spindown during
periods of inactivity.
</p><p>The daemon provides a modern REST API interface along with an integrated Web UI.
This allows you to monitor array health, trigger maintenance tasks, and
configure the daemon through a user-friendly browser interface or programmatically
via the API.
</p></div>
<div class="manual-section-level-1">
<h1 id="sec3" class="manual-title-level-1">
Options
</h1>
<p>The SnapRAID Daemon provides the following options:
</p><div class="manual-option-list">
<div class="manual-option-entry">
<div class="manual-option-name">
-c, --conf CONFIG
</div><div class="manual-option-description">
Specifies the path to the configuration file. Default:
<b>$PREFIX/etc/snapraidd.conf</b> and <b>/etc/snapraidd.conf</b> if
not found. The $PREFIX variable represents the installation
path chosen at build time (typically via the <b>--prefix</b>
argument to the configure script).
</div>
</div>
</div>
<div class="manual-option-list">
<div class="manual-option-entry">
<div class="manual-option-name">
-f, --foreground
</div><div class="manual-option-description">
Runs the process in the foreground. This prevents the
daemon from detaching from the terminal (daemonizing).
</div>
</div>
</div>
<div class="manual-option-list">
<div class="manual-option-entry">
<div class="manual-option-name">
-p, --pidfile FILE
</div><div class="manual-option-description">
Overrides the default location for the PID file. Default:
<b>/run/snapraidd.pid</b>.
</div>
</div>
</div>
<div class="manual-option-list">
<div class="manual-option-entry">
<div class="manual-option-name">
-N, --no-cache
</div><div class="manual-option-description">
Forces the daemon to load web interface assets directly from the
filesystem for every request, bypassing internal memory caching.
This is intended for development environments to allow real-time
testing of UI changes.
This option is only effective when <b>net_web_root</b> is configured
to point to an expanded directory on the filesystem.
It has no effect if the web assets are being served from a
compressed .zip file, as the daemon must crawl and index the
archive's contents at startup regardless of this flag.
This option is not recommended for production use due to the
increased I/O overhead and for security reasons, as it could
potentially expose the system to directory traversal
vulnerabilities if not properly isolated.
</div>
</div>
</div>
<div class="manual-option-list">
<div class="manual-option-entry">
<div class="manual-option-name">
-v, --verbose
</div><div class="manual-option-description">
Verbose logging including all HTTP requests.
</div>
</div>
</div>
<div class="manual-option-list">
<div class="manual-option-entry">
<div class="manual-option-name">
-H, --help
</div><div class="manual-option-description">
Prints a short help screen.
</div>
</div>
</div>
<div class="manual-option-list">
<div class="manual-option-entry">
<div class="manual-option-name">
-V, --version
</div><div class="manual-option-description">
Prints the program version.
</div>
</div>
</div>
</div>
<div class="manual-section-level-1">
<h1 id="sec4" class="manual-title-level-1">
Configuration
</h1>
<p>The SnapRAID Daemon is configured via a plain-text .conf file,
defaulting to $PREFIX/etc/snapraidd.conf and if not found to
/etc/snapraidd.conf. The $PREFIX variable represents the installation
path chosen at build time (typically via the <b>--prefix</b> argument to
the configure script).
</p><p>This file governs the behavior of the automation engine, network
accessibility, safety interlocks, and hardware monitoring parameters.
</p><p>The configuration system is designed with a "hybrid" management
philosophy to balance convenience with system security:
</p><div class="manual-tag-list">
<div class="manual-tag-entry">
<div class="manual-tag-name">
Static_Parameters
</div><div class="manual-tag-description">
Critical security and networking settings, such
as the listening port (net_port) and the system user for
scripts (script_run_as_user), are immutable via the REST API.
These require manual file edits followed by a SIGHUP signal
(e.g., systemctl reload snapraidd) to take effect.
</div>
</div>
</div>
<div class="manual-tag-list">
<div class="manual-tag-entry">
<div class="manual-tag-name">
Dynamic_Parameters
</div><div class="manual-tag-description">
Operational settings, like the maintenance
schedule or scrub percentages, can be modified in real-time
via the PATCH /snapraid/v1/config endpoint. Changes made through
the API are instantly applied to the running process and
persisted back to the configuration file, preserving any
manual comments.
</div>
</div>
</div>
<p>To prevent race conditions, users should avoid editing the
configuration file manually while simultaneously issuing configuration
updates via the REST API. If a manual edit is performed while the
daemon is active, ensure a reload is triggered immediately to
synchronize the daemon's internal memory state with the disk.
</p><p>For a comprehensive view of how these settings are applied in a
real-world environment, refer to the <b>snapraidd.conf.example</b> file
typically located in the documentation directory of the installation.
</p><div class="manual-section-level-2">
<h2 id="sec4-1" class="manual-title-level-2">
Network &amp; REST API
</h2>
<p>These settings control the network interface. These options are not
visible from the REST API. They require a manual edit of the
configuration file and a configuration reload (SIGHUP) to apply.
</p><div class="manual-section-level-3">
<h3 id="sec4-1-1" class="manual-title-level-3">
net_enabled
</h3>
<p>Acts as the master toggle for the network interface. When set to 1,
the daemon enables the REST API and prepares to serve the web dashboard.
If set to 0 or left blank, the daemon operates in a secure, local-only
mode, and no network ports are opened.
</p></div>
<div class="manual-section-level-3">
<h3 id="sec4-1-2" class="manual-title-level-3">
net_port
</h3>
<p>Defines the specific IP address and port(s) to which the daemon binds.
The format follows [IP_ADDRESS:]PORT[s].
</p><div class="manual-tag-list">
<div class="manual-tag-entry">
<div class="manual-tag-name">
IPv4/IPv6
</div><div class="manual-tag-description">
Bind to specific local addresses (e.g., 127.0.0.1:8080 or
[::1]:8080).
</div>
</div>
<div class="manual-tag-entry">
<div class="manual-tag-name">
Wildcard
</div><div class="manual-tag-description">
Providing only a port (e.g., 8080) binds to all available
IPv4 interfaces (0.0.0.0).
</div>
</div>
<div class="manual-tag-entry">
<div class="manual-tag-name">
Multiple_Ports
</div><div class="manual-tag-description">
Multiple listeners can be configured by providing a
comma-separated list.
</div>
</div>
</div>
<p>If left unset, the daemon defaults to 127.0.0.1:8080. Modification
requires a configuration reload and is restricted from API access.
</p></div>
<div class="manual-section-level-3">
<h3 id="sec4-1-3" class="manual-title-level-3">
net_acl
</h3>
<p>Restricts API and dashboard access to specific client IP addresses or
subnets using a comma-separated Access Control List (ACL).
</p><p>The syntax uses + to allow and - to deny, supporting CIDR notation
(e.g., /24). If any rules are defined, the daemon adopts a "deny by default"
stance. The rules are processed sequentially, and the last matching rule
determines the outcome.
If unset, it defaults to +127.0.0.1.
</p></div>
<div class="manual-section-level-3">
<h3 id="sec4-1-4" class="manual-title-level-3">
net_security_headers
</h3>
<p>When enabled (1), the daemon injects several browser-level security
hardening headers into every HTTP response. These include
Content-Security-Policy (restricting resource loading),
X-Frame-Options (preventing clickjacking via iframes),
X-Content-Type-Options (disabling MIME-sniffing),
and Referrer-Policy.
</p><p>This should only be disabled (0) if the daemon is behind a reverse
proxy (like Nginx or Traefik) that is already configured to handle
these security headers.
</p></div>
<div class="manual-section-level-3">
<h3 id="sec4-1-5" class="manual-title-level-3">
net_allowed_origin
</h3>
<p>Configures Cross-Origin Resource Sharing (CORS) to determine which web
applications can interact with the API.
</p><div class="manual-tag-list">
<div class="manual-tag-entry">
<div class="manual-tag-name">
self
</div><div class="manual-tag-description">
(Default/Recommended) Dynamically reflects the 'Host' header
of the request, allowing the built-in UI to work across various hostnames or IPs.
</div>
</div>
<div class="manual-tag-entry">
<div class="manual-tag-name">
none
</div><div class="manual-tag-description">
Omits CORS headers entirely, blocking browser-based access from any origin.
</div>
</div>
<div class="manual-tag-entry">
<div class="manual-tag-name">
URL
</div><div class="manual-tag-description">
Restricts access to a specific origin (e.g., http://192.168.1.50:3000).
</div>
</div>
</div>
</div>
<div class="manual-section-level-3">
<h3 id="sec4-1-6" class="manual-title-level-3">
net_config_full_access
</h3>
<p>A security flag that determines whether sensitive configuration parameters
can be modified via the REST API.
</p><p>By default (0), security-sensitive options are strictly read-only to
prevent unauthorized system modifications or privilege escalation
through the web interface.
</p><p>When set to 1, the following configuration options become accessible
for modification via PATCH requests:
</p><div class="manual-tag-list">
<div class="manual-tag-entry">
<div class="manual-tag-name">
script_run_as_user
</div><div class="manual-tag-description">
The account used for executing pre/post scripts.
</div>
</div>
<div class="manual-tag-entry">
<div class="manual-tag-name">
script_pre_run
</div><div class="manual-tag-description">
The absolute path to the pre-execution script.
</div>
</div>
<div class="manual-tag-entry">
<div class="manual-tag-name">
script_post_run
</div><div class="manual-tag-description">
The absolute path to the post-execution script.
</div>
</div>
<div class="manual-tag-entry">
<div class="manual-tag-name">
log_directory
</div><div class="manual-tag-description">
The persistent storage path for command outputs.
</div>
</div>
<div class="manual-tag-entry">
<div class="manual-tag-name">
log_retention_days
</div><div class="manual-tag-description">
The duration for which log files are kept.
</div>
</div>
<div class="manual-tag-entry">
<div class="manual-tag-name">
notify_run_as_user
</div><div class="manual-tag-description">
The account used for notification commands.
</div>
</div>
<div class="manual-tag-entry">
<div class="manual-tag-name">
notify_heartbeat
</div><div class="manual-tag-description">
The command used for health monitoring pings.
</div>
</div>
<div class="manual-tag-entry">
<div class="manual-tag-name">
notify_result
</div><div class="manual-tag-description">
The command used for sending task reports.
</div>
</div>
<div class="manual-tag-entry">
<div class="manual-tag-name">
notify_result_level
</div><div class="manual-tag-description">
The severity threshold for sending notifications.
</div>
</div>
</div>
</div>
<div class="manual-section-level-3">
<h3 id="sec4-1-7" class="manual-title-level-3">
net_web_root
</h3>
<p>Specifies the source of the web dashboard assets. The daemon supports
both a standard directory and a single compressed ZIP file for asset
delivery.
</p><p>The daemon resolves the location of the assets based on the following
rules:
</p><div class="manual-tag-list">
<div class="manual-tag-entry">
<div class="manual-tag-name">
ZIP_Filename
</div><div class="manual-tag-description">
If a simple filename is provided (e.g., commander.zip),
the daemon searches for it in $PREFIX/share/snapraidd/ or
/usr/share/snapraidd/.
</div>
</div>
<div class="manual-tag-entry">
<div class="manual-tag-name">
ZIP_Path
</div><div class="manual-tag-description">
If a path to a ZIP file is provided, it must be absolute
(e.g., /opt/snapraid/ui.zip). The daemon will attempt to use
this specific file exclusively and will not perform a search
in system directories.
</div>
</div>
<div class="manual-tag-entry">
<div class="manual-tag-name">
Directories
</div><div class="manual-tag-description">
If the target is a directory rather than a ZIP archive,
the path must be absolute (e.g., /var/www/snapraid-ui/).
</div>
</div>
</div>
<p>If the specified path or filename cannot be resolved, if a directory
path is not absolute, or if the ZIP archive is inaccessible or
malformed, the built-in HTTP server will be unable to serve the web
interface.
</p></div>
</div>
<div class="manual-section-level-2">
<h2 id="sec4-2" class="manual-title-level-2">
Automation &amp; Maintenance
</h2>
<p>These settings control the automation and maintenance tasks run by
the SnapRAID daemon.
</p><p>For security reasons, some of them can be set via the REST API only if the
net_config_full_access option is enabled.
</p><div class="manual-section-level-3">
<h3 id="sec4-2-1" class="manual-title-level-3">
maintenance_schedule
</h3>
<p>Defines the timing for the automated maintenance sequence, which
consists of a sync, followed by a scrub, and concluding with a report.
If this option is unset, automated maintenance is disabled.
</p><p>The format must be either "daily HH:MM" or "weekly [Day] HH:MM".
Hours are specified in a 24-hour format (00-23), and days are
represented by their short names (Mon, Tue, Wed, Thu, Fri, Sat, Sun).
</p></div>
<div class="manual-section-level-3">
<h3 id="sec4-2-2" class="manual-title-level-3">
sync_threshold_deletes
</h3>
<p>Sets the maximum number of deleted or missing files allowed before a
sync operation is automatically aborted. This serves as a safety
mechanism to prevent accidental parity loss due to unintended mass
deletions. This threshold is enforced during scheduled runs and
maintenance API calls, but is bypassed for standalone sync API
requests to allow for manual overrides.
Set to 0 to disable this check.
</p></div>
<div class="manual-section-level-3">
<h3 id="sec4-2-3" class="manual-title-level-3">
sync_threshold_updates
</h3>
<p>Sets the maximum number of modified or updated files allowed before a
sync operation is aborted. Similar to the delete threshold, this
prevents the parity from being overwritten if an unexpected number
of files have changed. This is enforced during scheduled runs but
bypassed for manual standalone sync requests.
Set to 0 to disable this check.
</p></div>
<div class="manual-section-level-3">
<h3 id="sec4-2-4" class="manual-title-level-3">
sync_prehash
</h3>
<p>If set to 1, the sync command is executed with the --prehash option.
This calculates hashes before moving data to verify integrity,
helping to prevent silent errors caused by faulty memory.
If missing or set to 0, no pre-hashing is performed.
</p></div>
<div class="manual-section-level-3">
<h3 id="sec4-2-5" class="manual-title-level-3">
sync_force_zero
</h3>
<p>If set to 1, the daemon allows a sync to proceed even if it detects
files that have shrunk to zero size since the last run.
By default (missing or 0), the daemon will halt the sync to protect
against potential data corruption or accidental file clearing.
</p></div>
<div class="manual-section-level-3">
<h3 id="sec4-2-6" class="manual-title-level-3">
scrub_percentage
</h3>
<p>Determines the portion of the array verified after a successful sync.
You may use decimal points to specify fractions of a percent
(e.g., 0.7 to verify 0.7% of the array).
If missing or set to 0, the scrub phase is skipped entirely.
</p></div>
<div class="manual-section-level-3">
<h3 id="sec4-2-7" class="manual-title-level-3">
scrub_older_than
</h3>
<p>Specifies that only blocks older than the defined number of days
should be scrubbed. This allows the daemon to focus verification on
older data while skipping recently synced blocks.
If missing or set to 0, no age-based filtering is applied.
</p></div>
</div>
<div class="manual-section-level-2">
<h2 id="sec4-3" class="manual-title-level-2">
Disk Monitoring &amp; Power
</h2>
<p>The following settings manage how the daemon interacts with physical
hardware to monitor disk health and optimize energy consumption
</p><div class="manual-section-level-3">
<h3 id="sec4-3-1" class="manual-title-level-3">
probe_interval_minutes
</h3>
<p>Controls the frequency at which the daemon checks disk SMART attributes.
To prevent unnecessary disk wear, the daemon only performs this check
if the disks are already spinning.
If set to 0 or left blank, SMART monitoring is disabled.
</p></div>
<div class="manual-section-level-3">
<h3 id="sec4-3-2" class="manual-title-level-3">
spindown_idle_minutes
</h3>
<p>Manages power consumption by automatically spinning down disks after
the specified duration of inactivity.
</p><p>Unlike the internal task logic of the daemon, this timer monitors the
global activity of the disks across the entire operating system.
A disk will only be spun down if it has remained completely idle for
the specified period. If any other application, service, or system
process accesses the disk, the idle timer is reset. The daemon will
not force a spindown if the disk is currently in use by the system.
</p><p>If this option is unset, the daemon will not manage disk power states,
relying instead on the OS or hardware controllers.
</p></div>
<div class="manual-section-level-3">
<h3 id="sec4-3-3" class="manual-title-level-3">
script_pre_run/script_post_run
</h3>
<p>Defines absolute paths to custom scripts to be executed immediately before
or after the sync, scrub, check, or fix commands. These scripts allow
for custom logic such as mounting drives or sending custom alerts.
</p><ul>
<li>
The path must be absolute (starting with /).
</li>
<li>
The script must not be world-writable (recommended permissions: 700 or 755).
</li>
<li>
The script owner must match the daemon user or be root.
</li>
<li>
The script must contain a valid shebang (e.g., #!/bin/sh).
</li>
</ul>
</div>
<div class="manual-section-level-3">
<h3 id="sec4-3-4" class="manual-title-level-3">
script_run_as_user
</h3>
<p>Specifies the user account used to execute the pre-run and post-run
scripts. If this is missing or blank, scripts are executed with the
same privileges as the daemon process.
</p></div>
</div>
<div class="manual-section-level-2">
<h2 id="sec4-4" class="manual-title-level-2">
Logging &amp; Notifications
</h2>
<p>These settings control the logging and notification operations performed
by the SnapRAID daemon.
</p><div class="manual-section-level-3">
<h3 id="sec4-4-1" class="manual-title-level-3">
log_directory
</h3>
<p>The log_directory defines where the output of individual SnapRAID
commands is stored. If left unset, the daemon defaults to
/var/log/snapraid.
</p><p>Setting this option to an empty value (log_directory = ) will
explicitly disable the saving of command output to persistent files.
</p><p>IMPORTANT: While it is possible to leave this empty to avoid saving files,
these logs are used by the daemon to reconstruct the past state of the
array (e.g., tracking the last successful sync or scrub). If no log
directory is provided, the daemon will lose its "memory" of previous
task results every time it is restarted.
</p></div>
<div class="manual-section-level-3">
<h3 id="sec4-4-2" class="manual-title-level-3">
log_retention_days
</h3>
<p>To prevent your storage from filling up, log_retention_days sets the
age at which old command logs are deleted. Logs are kept indefinitely
if this is set to 0 or left unset.
</p></div>
<div class="manual-section-level-3">
<h3 id="sec4-4-3" class="manual-title-level-3">
notify_syslog_enabled
</h3>
<p>When set to 1, daemon activity is sent to the operating system system
log (syslog/journald). While lifecycle events like starting and
stopping are always captured, task-related messages are filtered by
<b>notify_syslog_level</b>.
</p></div>
<div class="manual-section-level-3">
<h3 id="sec4-4-4" class="manual-title-level-3">
notify_syslog_level
</h3>
<p>Sets the minimum severity for syslog task entries.
Possible values are <b>info</b>, <b>warning</b>, <b>error</b>, and <b>critical</b>.
The default is <b>error</b>.
</p></div>
<div class="manual-section-level-3">
<h3 id="sec4-4-5" class="manual-title-level-3">
notify_heartbeat
</h3>
<p>Defines a command to run ONLY if the maintenance task was successful
(it is not triggered by other tasks, such as heal or undelete).
This is ideal for external monitoring services like "Dead Man's Snitch"
or Healthchecks.io. If this ping stops, it indicates the server is down
or the task is failing.
</p></div>
<div class="manual-section-level-3">
<h3 id="sec4-4-6" class="manual-title-level-3">
notify_result
</h3>
<p>Specifies a command triggered after every high-level task (maintenance,
heal, or undelete). The command is only executed if the task's result
matches the notify_result_level. The daemon pipes a structured,
plain-text task report directly into the command's stdin.
</p><p>The daemon automatically chooses a wide (80-col) or narrow (32-col)
report based on the command and arguments used (e.g., presence of "mail"
or "smtps"). Users can manually override this by adding --wide or
--narrow to the command string. These tags are stripped before execution.
</p><p>Before execution, the daemon scans the command string and replaces the
following tokens with dynamic values corresponding to the current
task's state and results:
</p><div class="manual-tag-list">
<div class="manual-tag-entry">
<div class="manual-tag-name">
%s
</div><div class="manual-tag-description">
Subject string (e.g., "[ERROR] SnapRAID Maintenance").
</div>
</div>
<div class="manual-tag-entry">
<div class="manual-tag-name">
%l
</div><div class="manual-tag-description">
Task level (critical, error, warning, info, debug).
</div>
</div>
<div class="manual-tag-entry">
<div class="manual-tag-name">
%n
</div><div class="manual-tag-description">
ntfy priority (urgent, high, default, low, min).
</div>
</div>
<div class="manual-tag-entry">
<div class="manual-tag-name">
%t
</div><div class="manual-tag-description">
ntfy tag (skull, warning, default, -1, +1, heavy_check_mark).
</div>
</div>
</div>
<p>If the command contains --mail-from or --mail-rcpt, the daemon
automatically prepends standard email headers (From, To, Subject)
followed by a blank line to the report text. This ensures
compatibility with curl's SMTP engine.
</p><p>When using curl for SMTP, it is recommended to use the --netrc flag.
This allows curl to read credentials from a local file rather than
exposing passwords in the command line or process list.
</p><p>File format (~/.netrc):
</p><pre>
machine smtp.gmail.com
login your_email@gmail.com
password your-16-char-app-password
</pre>
<p>If <b>notify_run_as_user</b> is configured, ensure that user has a valid
home directory containing a .netrc file with 600 permissions for SMTP
authentication. Failure to do so may result in authentication errors
(e.g., curl error 55).
</p></div>
<div class="manual-section-level-3">
<h3 id="sec4-4-7" class="manual-title-level-3">
notify_result_level
</h3>
<p>Controls the filter for <b>notify_result</b>. The notification is sent only
if the task result is equal to or more severe than this level.
Valid values are <b>info</b> (always send), <b>warning</b>, <b>error</b>, and <b>critical</b>.
The default is <b>error</b>.
</p></div>
<div class="manual-section-level-3">
<h3 id="sec4-4-8" class="manual-title-level-3">
notify_differences
</h3>
<p>If set to 1, the daemon logs a detailed list of file changes discovered
before a sync begins. If set to 0 or missing, no difference report is
generated.
</p></div>
</div>
<div class="manual-section-level-2">
<h2 id="sec4-5" class="manual-title-level-2">
Notification Examples:
</h2>
<p>The following examples demonstrate common notification and heartbeat
configurations
</p><div class="manual-section-level-3">
<h3 id="sec4-5-1" class="manual-title-level-3">
External Heartbeat Monitoring (Healthchecks.io)
</h3>
<p>To monitor that automated maintenance is running successfully, use a service
like Healthchecks.io.
</p><p>In this example, curl sends a simple GET request to a unique monitoring URL.
The flags ensure that curl fails silently on server errors (-f), does not hang
indefinitely (--max-time), and attempts to overcome transient network issues (--retry).
</p><pre>
notify_heartbeat = curl -f --max-time 30 --retry 3 <a href="https://hc-ping.com/your_private_uuid">https://hc-ping.com/your_private_uuid</a>
</pre>
</div>
<div class="manual-section-level-3">
<h3 id="sec4-5-2" class="manual-title-level-3">
Push Notifications (ntfy.sh)
</h3>
<p>This uses curl to send the report as a POST request to a push notification service.
It utilizes the --narrow flag to ensure the report is readable on mobile devices
and maps SnapRAID status to ntfy titles, priorities, and emojis via placeholders.
</p><pre>
notify_result = curl --narrow -f --max-time 30 --retry 3 -H "Title: %s" -H "Priority: %n" -H "Tag: %t" -H "Email: your_email@example.com" --data-binary @- <a href="https://ntfy.sh/your_private_topic">https://ntfy.sh/your_private_topic</a>
</pre>
</div>
<div class="manual-section-level-3">
<h3 id="sec4-5-3" class="manual-title-level-3">
Local System Mail (mail)
</h3>
<p>A traditional approach using the standard Linux mail utility. This is
ideal if you have a local Mail Transfer Agent (MTA) like Postfix or
Exim already configured on your system.
</p><pre>
notify_result = mail -s "%s" your_user@localhost
</pre>
</div>
<div class="manual-section-level-3">
<h3 id="sec4-5-4" class="manual-title-level-3">
Direct Delivery (SMTP-over-SSL)
</h3>
<p>This leverages curl's built-in SMTP engine for direct delivery to an
external provider. By using the --netrc option, login credentials
remain secured in a separate file rather than being exposed in the
process list or logs.
</p><pre>
notify_result = curl --netrc --url smtps://smtp.gmail.com:465 --ssl-reqd --mail-from your_email@gmail.com --mail-rcpt your_email@gmail.com --upload-file -
</pre>
</div>
</div>
</div>
<div class="manual-section-level-1">
<h1 id="sec5" class="manual-title-level-1">
REST API
</h1>
<p>The SnapRAID Daemon provides a comprehensive RESTful JSON interface
for monitoring and controlling the parity array.
</p><p>For complete technical documentation, including request schemas and
specific error codes, please refer to the <b>snapraidd.yaml</b> OpenAPI
specification file typically located in the documentation directory of
the installation.
</p><div class="manual-section-level-2">
<h2 id="sec5-1" class="manual-title-level-2">
Maintenance &amp; Recovery
</h2>
<p>The API prioritizes orchestrated workflows over raw command execution.
These high-level endpoints encapsulate complex SnapRAID logic into
single, automated tasks that manage the lifecycle of the array and the
recovery of data.
They typically end with a <b>report</b> command that generates a notification
with a full report of the result of the operation.
</p><div class="manual-section-level-3">
<h3 id="sec5-1-1" class="manual-title-level-3">
/snapraid/v1/maintenance
</h3>
<p>Triggers the complete automated maintenance sequence. It orchestrates
a parity synchronization, followed by a data integrity scrub, and
concludes by issuing a system-wide health report.
This is the primary endpoint for routine array upkeep.
This task is subject to the 'sync_threshold_deletes' and
'sync_threshold_update' safety checks defined in the configuration.
The percentage of the array checked and the age filter are determined
by the 'scrub_percentage' and 'scrub_older_than' settings.
</p><p>Example:
</p><pre>
curl -X POST <a href="http://localhost:8080/snapraid/v1/maintenance">http://localhost:8080/snapraid/v1/maintenance</a>
</pre>
<p>It is implemented with the sequence of commands: up, diff, sync, scrub, and
report.
</p></div>
<div class="manual-section-level-3">
<h3 id="sec5-1-2" class="manual-title-level-3">
/snapraid/v1/heal
</h3>
<p>Executes a specialized silent error recovery workflow. The daemon
automatically runs a targeted fix operation to repair detected corruption,
immediately follows up with a verification scrub of the affected
blocks to ensure the recovery was successful, and concludes by issuing
a report of the result.
</p><p>Example:
</p><pre>
curl -X POST <a href="http://localhost:8080/snapraid/v1/heal">http://localhost:8080/snapraid/v1/heal</a>
</pre>
<p>It is implemented with the sequence of commands: up, fix -e, scrub -p bad,
and report.
</p></div>
<div class="manual-section-level-3">
<h3 id="sec5-1-3" class="manual-title-level-3">
/snapraid/v1/undelete
</h3>
<p>Invokes the SnapRAID restoration engine to recover files that have been
deleted from data disks but still exist in the parity information.
This is used to roll back accidental deletions to the state of the
last successful synchronization.
</p><p>Example:
</p><pre>
curl -s -X POST <a href="http://localhost:8080/snapraid/v1/undelete">http://localhost:8080/snapraid/v1/undelete</a> \
&nbsp;&nbsp;&nbsp;&nbsp;-H "Content-Type: application/json" \
&nbsp;&nbsp;&nbsp;&nbsp;-d '{ "filters": [ "*.txt" ] }'
</pre>
<p>It is implemented with the sequence of commands: up, fix -m -f ...,
and report.
</p></div>
<div class="manual-section-level-3">
<h3 id="sec5-1-4" class="manual-title-level-3">
/snapraid/v1/suspend_idle
</h3>
<p>Probes the disks to gather their latest activity state and executes a
conditional spindown operation. The daemon will only issue the
down_idle command to disks that have exceeded the
'spindown_idle_minutes' threshold. In this case, no report is
generated.
</p><p>Example:
</p><pre>
curl -X POST <a href="http://localhost:8080/snapraid/v1/suspend_idle">http://localhost:8080/snapraid/v1/suspend_idle</a>
</pre>
<p>It is implemented with the sequence of commands: probe, down_idle.
</p></div>
</div>
<div class="manual-section-level-2">
<h2 id="sec5-2" class="manual-title-level-2">
Monitoring &amp; Inventory
</h2>
<p>These endpoints provide high-level visibility into the global state of
the storage stack and the health of the underlying physical hardware.
</p><div class="manual-section-level-3">
<h3 id="sec5-2-1" class="manual-title-level-3">
/snapraid/v1/array
</h3>
<p>Provides a high-level telemetry summary of the entire parity array.
This includes global metadata such as total capacity across all disks,
aggregate space utilization, the current state of parity protection,
and the timestamp of the last successful maintenance.
</p><p>Example:
</p><pre>
curl -s <a href="http://localhost:8080/snapraid/v1/array">http://localhost:8080/snapraid/v1/array</a> | jq
</pre>
</div>
<div class="manual-section-level-3">
<h3 id="sec5-2-2" class="manual-title-level-3">
/snapraid/v1/disks
</h3>
<p>Returns a comprehensive inventory of every physical disk associated
with the SnapRAID configuration. It reports real-time hardware
metrics including SMART health status, temperature, and the current
power state (Active/Spin-up vs. Standby/Spin-down).
</p><p>Example:
</p><pre>
curl -s <a href="http://localhost:8080/snapraid/v1/disks">http://localhost:8080/snapraid/v1/disks</a> | jq
</pre>
</div>
</div>
<div class="manual-section-level-2">
<h2 id="sec5-3" class="manual-title-level-2">
Configuration
</h2>
<p>Provides a programmatic interface to retrieve and modify the
operational parameters of the daemon in real-time.
</p><div class="manual-section-level-3">
<h3 id="sec5-3-1" class="manual-title-level-3">
/snapraid/v1/config
</h3>
<p>Retrieves and updates the current runtime configuration parameters of
the snapraidd service. Changes are applied instantly to memory and
persisted to the configuration file.
Note that certain networking and security settings are read-only and
require a manual edit and SIGHUP.
</p><p>Example:
</p><pre>
curl -X GET <a href="http://localhost:8080/snapraid/v1/config">http://localhost:8080/snapraid/v1/config</a> | jq
curl -X PATCH <a href="http://localhost:8080/snapraid/v1/config">http://localhost:8080/snapraid/v1/config</a> \
&nbsp;&nbsp;&nbsp;&nbsp;-d '{ "probe_interval_minutes": 10 }'
</pre>
</div>
</div>
<div class="manual-section-level-2">
<h2 id="sec5-4" class="manual-title-level-2">
Activity Control
</h2>
<p>All operations that modify the array state are asynchronous; they
return an HTTP 202 Accepted status and queue a task for background
execution.
</p><p>Because tasks run in the background, these endpoints are used to
monitor progress and manage the execution lifecycle.
</p><div class="manual-section-level-3">
<h3 id="sec5-4-1" class="manual-title-level-3">
/snapraid/v1/activity
</h3>
<p>Provides real-time telemetry for the currently executing task,
including a progress percentage, estimated time of completion (ETA),
and a live stream of the process log output.
If no task is in execution, it returns the last completed task.
</p><p>Example:
</p><pre>
curl -s <a href="http://localhost:8080/snapraid/v1/activity">http://localhost:8080/snapraid/v1/activity</a> | jq
</pre>
</div>
<div class="manual-section-level-3">
<h3 id="sec5-4-2" class="manual-title-level-3">
/snapraid/v1/tasks
</h3>
<p>Lists all tasks waiting, the task currently active, and the task
execution history. The response from this entry point can be very long,
as the history may span up to a month.
</p><p>Example:
</p><pre>
curl -s <a href="http://localhost:8080/snapraid/v1/tasks">http://localhost:8080/snapraid/v1/tasks</a> | jq
</pre>
</div>
<div class="manual-section-level-3">
<h3 id="sec5-4-3" class="manual-title-level-3">
/snapraid/v1/stop
</h3>
<p>Terminates the currently running task (such as sync or scrub) by
sending a SIGTERM signal to the background process.
</p><p>Example:
</p><pre>
curl -X POST <a href="http://localhost:8080/snapraid/v1/stop">http://localhost:8080/snapraid/v1/stop</a>
</pre>
</div>
</div>
<div class="manual-section-level-2">
<h2 id="sec5-5" class="manual-title-level-2">
State and Cache Management
</h2>
<p>To optimize performance and support lightweight monitoring (such as
desktop status bars), the daemon implements a state synchronization
mechanism via the /v1/state endpoint.
</p><div class="manual-section-level-3">
<h3 id="sec5-5-1" class="manual-title-level-3">
/snapraid/v1/state
</h3>
<p>The response provides a high-level summary of the daemon's current
operation and health, alongside a pulse object containing sequence
counters.
</p><p>The pulse object contains counters used for cache invalidation. Each
field corresponds directly to a data-heavy API entry point.
</p><p>If a counter has not changed since the last request, the corresponding
entry point is guaranteed to return the same data. If a counter is
different, the underlying subsystem state has evolved, and the entry
point will potentially return updated information.
</p><p>Note that the counters are not necessarily monotonically increasing
because they are reset if the daemon restarts. You should compare
them only for equality.
</p><p>Example:
</p><pre>
curl -X GET <a href="http://localhost:8080/snapraid/v1/state">http://localhost:8080/snapraid/v1/state</a> | jq
</pre>
</div>
</div>
<div class="manual-section-level-2">
<h2 id="sec5-6" class="manual-title-level-2">
Schedule
</h2>
<p>The schedule entry point allows batching multiple SnapRAID commands
into a single sequential session. Upon submission, the daemon executes
tasks in the order provided, maintaining a single-threaded execution
flow.
</p><p>The daemon enforces strict serialization for all operations. Only one
task can access the array at a time. All scheduled tasks are placed
in an execution queue and executed in their scheduled order.
</p><p>To ensure data safety, the daemon employs a fail-fast policy where any
command failure triggers the immediate cancellation of all subsequent
tasks within the same schedule request. This prevents operations from
running against an unstable or inconsistent array state while
preserving any independent tasks previously queued in the system.
</p><p>The only exception is the report command, which acts as a mandatory
finalizer. It will execute regardless of previous failures to ensure
the generation of a report that reflects the final state of the system.
</p><div class="manual-section-level-3">
<h3 id="sec5-6-1" class="manual-title-level-3">
/snapraid/v1/schedule
</h3>
<p>Queues a sequence of standard SnapRAID operations.
</p><p>Example:
</p><pre>
curl -X POST <a href="http://localhost:8080/snapraid/v1/schedule">http://localhost:8080/snapraid/v1/schedule</a> \
&nbsp;&nbsp;&nbsp;&nbsp;-d '{"tasks": [{"command": "diff"}, {"command": "report"}]}'
</pre>
<p>Supported Commands:
</p><div class="manual-tag-list">
<div class="manual-tag-entry">
<div class="manual-tag-name">
up
</div><div class="manual-tag-description">
Spins up all drives in the array.
</div>
</div>
<div class="manual-tag-entry">
<div class="manual-tag-name">
down
</div><div class="manual-tag-description">
Spins down array drives to save power.
</div>
</div>
<div class="manual-tag-entry">
<div class="manual-tag-name">
probe
</div><div class="manual-tag-description">
Verifies the power status of all configured disks and gathers
SMART information for those already spinning.
</div>
</div>
<div class="manual-tag-entry">
<div class="manual-tag-name">
smart
</div><div class="manual-tag-description">
Collects and parses SMART attributes from all drives to assess
physical health.
</div>
</div>
<div class="manual-tag-entry">
<div class="manual-tag-name">
diff
</div><div class="manual-tag-description">
Scans the array to identify changed, added, or deleted files
since the last sync.
</div>
</div>
<div class="manual-tag-entry">
<div class="manual-tag-name">
status
</div><div class="manual-tag-description">
Provides a summary of the array state, including parity
levels and data distribution.
</div>
</div>
<div class="manual-tag-entry">
<div class="manual-tag-name">
sync
</div><div class="manual-tag-description">
Updates the parity information to match the current state of
the data disks.
</div>
</div>
<div class="manual-tag-entry">
<div class="manual-tag-name">
scrub
</div><div class="manual-tag-description">
Verifies the integrity of the data and parity by recalculating
checksums for a portion of the array.
</div>
</div>
<div class="manual-tag-entry">
<div class="manual-tag-name">
check
</div><div class="manual-tag-description">
Performs a full verification of the array integrity without
modifying any data.
</div>
</div>
<div class="manual-tag-entry">
<div class="manual-tag-name">
fix
</div><div class="manual-tag-description">
Attempts to recover deleted files or repair corrupted data using
the parity information.
</div>
</div>
<div class="manual-tag-entry">
<div class="manual-tag-name">
report
</div><div class="manual-tag-description">
Generates a comprehensive summary of the last operations and
array statistics.
</div>
</div>
<div class="manual-tag-entry">
<div class="manual-tag-name">
down_idle
</div><div class="manual-tag-description">
Executes a conditional spindown operation of the disks that
have exceeded the 'spindown_idle_minutes' threshold.
</div>
</div>
</div>
</div>
</div>
</div>
<div class="manual-section-level-1">
<h1 id="sec6" class="manual-title-level-1">
Signals
</h1>
<p>This section defines how the daemon responds to standard Unix signals,
allowing for external process control and graceful management of the
service lifecycle.
</p><div class="manual-section-level-3">
<h3 class="manual-title-level-3">
SIGHUP
</h3>
<p>Reloads the configuration file and resets the internal state.
It also reloads the Web UI. This is the recommended way to
apply changes to static&nbsp;&nbsp;&nbsp;&nbsp;parameters without restarting the
service.
</p></div>
<div class="manual-section-level-3">
<h3 class="manual-title-level-3">
SIGTERM, SIGINT
</h3>
<p>Initiates a graceful shutdown. If a task is currently
running, the daemon attempts to terminate the child process
before exiting.
</p></div>
<div class="manual-section-level-3">
<h3 class="manual-title-level-3">
SIGQUIT
</h3>
<p>Immediately terminates the process using the default signal
action and may generate a core dump. This signal is intended
for emergency debugging and post mortem analysis of a hung
or misbehaving daemon. No cleanup or graceful shutdown is
performed.
</p></div>
</div>
<div class="manual-section-level-1">
<h1 id="sec7" class="manual-title-level-1">
Files
</h1>
<p>The following list specifies the default filesystem paths used by the
daemon for configuration, data persistence, and inter-process communication.
</p><div class="manual-section-level-3">
<h3 class="manual-title-level-3">
$PREFIX/etc/snapraidd.conf
</h3>
<p>The primary configuration file location. The $PREFIX variable
represents the installation path chosen at build time (typically
via the <b>--prefix</b> argument to the configure script). Common
values include <b>/usr/local</b> or <b>/usr</b>. If this file does not
exist, the daemon falls back to <b>/etc/snapraidd.conf</b>.
</p></div>
<div class="manual-section-level-3">
<h3 class="manual-title-level-3">
$PREFIX/share/snapraidd
</h3>
<p>The primary system data directory. This is the first location
searched for the web dashboard ZIP file (e.g., commander.zip).
If not found here, the daemon falls back to <b>/usr/share/snapraidd</b>.
</p></div>
<div class="manual-section-level-3">
<h3 class="manual-title-level-3">
/etc/snapraidd.conf
</h3>
<p>The secondary/system-wide configuration file location, used if
the prefix-specific file is missing.
</p></div>
<div class="manual-section-level-3">
<h3 class="manual-title-level-3">
/usr/share/snapraidd
</h3>
<p>The secondary/system-wide data directory, used as a fallback for
web assets.
</p></div>
<div class="manual-section-level-3">
<h3 class="manual-title-level-3">
/run/snapraidd.pid
</h3>
<p>Default PID file location.
</p></div>
<div class="manual-section-level-3">
<h3 class="manual-title-level-3">
/var/log/snapraid
</h3>
<p>Default directory for SnapRAID command execution logs. This
directory contains the output of the SnapRAID binary itself,
rather than the daemon's service logs.
</p></div>
</div>
</div>
</main>
</div>
<!-- Footer -->
<footer>
<div class="container footer-content">
<div class="footer-col">
<h3>SnapRAID</h3>
<p>Copyright &copy; 2026 Andrea Mazzoleni</p>
<p class="license">Distributed under GPL v3 License</p>
</div>
<div class="footer-col">
<h4>Community</h4>
<ul>
<li><a href="https://www.reddit.com/r/Snapraid/">Reddit r/snapraid</a></li>
<li><a href="https://sourceforge.net/p/snapraid/discussion/1677233/">SourceForge Forum</a></li>
<li><a href="https://github.com/amadvance/snapraid/">GitHub</a></li>
</ul>
</div>
</div>
</footer>
</body>
</html>