Restic systemd timer
for automated backups

Updated November 2026

Systemd timers catch missed runs, log to journald and wait for the network. Copy-paste units below.

On this page

Why systemd timers instead of cron

Cron fails silently. Systemd timers log to journald and report failures, and with Persistent=true and After=network-online.target they catch missed runs and wait for the network.

This guide works with any restic REST server.
Ours is zero-knowledge and ready in a minute: Starter $3/mo for 250 GB, or $30 a year with yearly billing. 30-day money-back on every paid plan.
Choose Starter, 250 GB

Step 1: Create the backup script

Save this as /usr/local/bin/restic-backup.sh and make it root-only with chmod 700. It backs up, then runs a structural check.

Shell
#!/bin/bash
set -euo pipefail
source /etc/restic/env

restic backup /home /etc /var/www \
  --tag "$(hostname)" \
  --exclude="/home/*/.cache" \
  --exclude="*/node_modules" \
  --exclude="*/.git"

restic check

Run retention with your cleanup key from one trusted machine, never from the hosts you back up; see retention on ServerCrate vaults.

Step 2: Store credentials securely

Credentials in a service unit show up in systemctl status, so keep them in a root-only env file:

Shell
sudo mkdir -p /etc/restic
sudo install -m 600 /dev/null /etc/restic/env
sudo tee /etc/restic/env <<EOF
RESTIC_REPOSITORY=rest:https://vaultuser:YOUR_TOKEN@a1b2c3d4.vault.servercrate.net/
RESTIC_PASSWORD=your-repository-password
EOF

Step 3: Create the systemd service unit

Save as /etc/systemd/system/restic-backup.service. It waits for the network, runs at low CPU and I/O priority, and allows four hours:

INI
[Unit]
Description=Restic offsite backup
After=network-online.target
Wants=network-online.target

[Service]
Type=oneshot
EnvironmentFile=/etc/restic/env
ExecStart=/usr/local/bin/restic-backup.sh
Nice=10
IOSchedulingClass=idle
TimeoutStartSec=4h

[Install]
WantedBy=multi-user.target

Step 4: Create the timer unit

Save as /etc/systemd/system/restic-backup.timer. It runs daily at 2:30 AM:

INI
[Unit]
Description=Run restic backup daily at 2:30 AM

[Timer]
OnCalendar=*-*-* 02:30:00
Persistent=true
RandomizedDelaySec=15m

[Install]
WantedBy=timers.target

Persistent=true fires a missed run on next boot. RandomizedDelaySec adds jitter so servers do not all hit the target at once.

The same timer pattern drives a scheduled Home Assistant offsite backup, with a hook that triggers an HA backup before restic runs. Running services in containers? Backing up Docker volumes with restic uses this same timer with a database pre-backup hook.

Step 5: Enable and verify

Reload, enable, then check the schedule and the first run's logs:

Shell
sudo systemctl daemon-reload
sudo systemctl enable --now restic-backup.timer

# Check timer is active
systemctl list-timers restic-backup.timer

# Check logs after first run
journalctl -u restic-backup.service -n 50 --no-pager

# Run manually to test
sudo systemctl start restic-backup.service

Adding failure notifications

Add OnFailure=notify-email@%n.service to the [Unit] section if you have mail set up, or ping a webhook or Healthchecks.io at the end of the script:

Shell
# Add to end of restic-backup.sh
curl -fsS --retry 3 https://hc-ping.com/your-uuid > /dev/null 2>&1 || true

Add a second, monthly timer for restic check --read-data-subset verification so silent corruption shows up early.

Where to point your restic repository

The Restic REST backend is the cleanest target for private offsite backup: set RESTIC_REPOSITORY to your vault connection string and this setup works as-is.

Common systemd timer patterns for restic

Three patterns come up in production:

Multiple schedules (hourly + daily)

Frequent snapshots of critical data alongside a daily backup: create two service and timer pairs with different scripts and schedules.

Network dependency

After=network-online.target stops the backup from running before the interface is up, which matters for remote repositories. Pair it with Wants=network-online.target.

OnCalendar syntax

Useful values: daily (same as *-*-* 00:00:00), Mon *-*-* 02:00:00 for Monday at 2am, *-*-* 02,14:30:00 for twice daily. Validate with systemd-analyze calendar "your expression".

Monitoring systemd backup health

Key commands to confirm backups ran:

  • Check timer status:systemctl list-timers restic-backup.timer shows the last and next run.
  • Read logs:journalctl -u restic-backup.service -n 100 --no-pager shows recent output and errors.
  • Check for failures:systemctl --failed lists every failed unit since boot.
  • Test manually:systemctl start restic-backup.service runs a backup now.

Why ServerCrate works well with systemd timers

A vault authenticates with a per-vault token over HTTPS, so unattended runs never prompt. See the hosted Restic backup server page.

Next step: your first offsite backup

On a Linux server, our installer does the setup in one line: it installs restic, creates your encryption password on your machine, takes a first snapshot and schedules a daily backup. The Vault page in your portal shows this line with your vault filled in.

Linux, one-line installer
curl -fsSL https://servercrate.net/install.sh | sudo sh -s -- --repo "rest:https://vaultuser:YOUR_TOKEN@a1b2c3d4.vault.servercrate.net/"

Add --dry-run to see what it would do without changing anything. On macOS or Windows, or to do it by hand, follow the setup guide.

Starter fits most single servers and small homelabs.
Starter $3/mo for 250 GB, or $30 a year with yearly billing. 30-day money-back on every paid plan. Or start with 10 GB free, no card.
Choose Starter, 250 GB

Restic systemd timer FAQ

Create a .service unit that calls your backup script and a .timer unit with OnCalendar set to your schedule. Enable the timer with systemctl enable --now restic-backup.timer. Use Persistent=true to catch missed runs.
Yes. Systemd timers handle missed runs, log to journald, support network dependencies, and report failures properly. Cron fails silently and has no native dependency system.
Store it in /etc/restic/env with chmod 600 and source the file in your backup script. Use EnvironmentFile in the service unit. Never put credentials directly in the unit file.
Run journalctl -u restic-backup.service -n 50 to see recent logs. Run systemctl list-timers restic-backup.timer to see the next scheduled run and when it last ran.

Keep going

Automate your backups today.

Free tier. Private vault ready in seconds. Point your systemd timer at it.

Need more than 10 GB? Starter is 250 GB for $30/yr, and every plan keeps the same vault and key when you move up.

Cancel anytime. 10 GB free tier never expires. No egress fees.