Linux & DevOps Ubuntu 24.04 LTS

Automating Scheduled Server Backups with Restic and Systemd Timers

A production guide to configuring encrypted, deduplicated backups on Linux with Restic, managed by native systemd service timers.
Z
Zaisha
Staff Writer · Verified Editor
Published Oct 22, 2026 · 3 min read · 242 words
Quick Overview

This deep-dive covers restic backups systemd timers with actionable analysis, practical implications, and expert insights.

Automating Scheduled Server Backups with Restic and Systemd Timers

Why Modern Backups Need Deduplication and Encryption

Traditional tar.gz backups consume excessive storage and lack encryption. Restic divides files into cryptographic content-addressed chunks, ensuring that files duplicated across snapshots take up zero extra space while remaining protected by AES-256 encryption.

Step 1: Install Restic

Install Restic from the Ubuntu repository:

sudo apt update && sudo apt install -y restic

Step 2: Initialize an Encrypted Repository

Initialize a backup repository on an external drive or backup partition:

export RESTIC_REPOSITORY="/mnt/backups/restic-repo"
export RESTIC_PASSWORD="YourStrongSecurePasswordHere"
restic init

Step 3: Creating the Backup Script

Create a backup script at /usr/local/bin/backup-server.sh with restricted permissions:

#!/usr/bin/env bash
set -euo pipefail

export RESTIC_REPOSITORY="/mnt/backups/restic-repo"
export RESTIC_PASSWORD_FILE="/etc/restic-password"

# Run backup
restic backup \
  --exclude="/var/cache" \
  --exclude="/var/tmp" \
  /etc /var/www /home

# Prune old snapshots (keep 7 daily, 4 weekly, 6 monthly)
restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 6 --prune
sudo chmod 700 /usr/local/bin/backup-server.sh

Step 4: Creating the Systemd Timer

Create the service unit at /etc/systemd/system/restic-backup.service:

[Unit]
Description=Restic Daily Backup Service

[Service]
Type=oneshot
ExecStart=/usr/local/bin/backup-server.sh

Create the accompanying timer at /etc/systemd/system/restic-backup.timer:

[Unit]
Description=Run Restic Backup Daily at 03:00

[Timer]
OnCalendar=*-*-* 03:00:00
Persistent=true

[Install]
WantedBy=timers.target
sudo systemctl daemon-reload
sudo systemctl enable --now restic-backup.timer
sudo systemctl list-timers

Your server will now execute automated encrypted backups every morning with automated retention management.

Tested & Verified Environment
Author Verified
Operating System: Ubuntu 24.04 LTS
Verification Date: Oct 22, 2026
Testing Methodology & Notes: Tested on Ubuntu 24.04 LTS with restic 0.16.4. Configured local backup repository on separate mount. Tested systemd service and timer execution. Snapshot verified.

Was this technical analysis helpful?

Your feedback informs our benchmark updates and ongoing article audits.

✓ Thank you for your feedback! Our editorial engineers review submissions weekly.

Frequently Asked Questions

Structured for search engines and AI answer systems (AEO/GEO).

Restic includes built-in encryption by default, performs chunk-level deduplication across snapshots, and verifies cryptographic integrity on every restore.

Systemd timers provide execution logging in journalctl, dependency chaining, and automatic retries if the machine was asleep or powered off at scheduled time.

Run restic restore latest --target /tmp/restore-test to verify full recovery integrity without overwriting production paths.

More answers in our FAQ hub.

Z
Zaisha

Tech journalist covering AI, software, and emerging technology with a focus on practical insights.

Testing Standards: Tutorials and guides are hands-on tested on Ubuntu Linux workstations before release.
View all articles by Zaisha

Practical Linux & Applied AI Newsletter

Get new tested tutorials and benchmark comparisons delivered directly to your inbox. Zero spam.

Join Weekly guides readers getting our weekly digest.

  • Practical Linux administration & terminal workflows
  • Tested open-source AI setups & benchmarks
  • Zero spam - unsubscribe anytime

Join Weekly guides readers · Weekly digest · Unsubscribe anytime. RSS

Continue Exploring