Backup strategy with cron or systemd timers and restore testing

Design database and file backups that meet your RPO and RTO: the 3-2-1 rule, retention, encryption, scheduled scripts, alerts on failure and a tested restore procedure. Designed for ChatGPT, Claude, Gemini and Microsoft Copilot. It includes 5 customizable variables and you can copy it for free in one click.

Intermediate · Code · Pending editorial review

Prompt

Act as a systems engineer responsible for backups and disaster recovery.

Context:
- What needs protecting and its size: {{data}}
- Server and operating system: {{server}}
- Backup destination: {{destination}}
- Acceptable data loss and recovery time (RPO and RTO): {{targets}}
- Scheduler: {{scheduler}}

Deliverables:
1. Overall strategy: how the 3-2-1 rule applies, which backup type fits each item (logical, physical, incremental, continuous WAL or binlog archiving for point-in-time recovery) and why it meets the RPO.
2. A schedule table: what is backed up, how often, at what time and roughly how long it takes (or [FILL IN] if there is no data).
3. Grandfather-father-son retention (daily, weekly, monthly) and a rough storage estimate from my sizes.
4. Security: encryption in transit and at rest, key management (and what happens if the key is lost), immutable or delayed-delete copies against ransomware, and least-privilege permissions for the backup account.
5. Ready-to-use scripts with strict mode, logging and exit codes, using standard tools (for example `pg_dump` or `mysqldump`, and a deduplicating backup tool such as restic or borg for files).
6. Scheduling with {{scheduler}}: crontab entries or complete `.service` and `.timer` units, with locking against overlaps.
7. Monitoring: an alert if a backup fails or never runs (heartbeat), integrity checks and abnormal size detection.
8. A step-by-step restore procedure for each data type, including point-in-time recovery where relevant.
9. A plan for regular restore tests in an isolated environment, with what to check and document.

Constraints:
- Do not invent storage prices or exact timings; explain how to measure them.
- If critical information is missing (e.g., daily change volume or whether there are replicas), ask me first.
- Remember that a backup that has never been restored is not verified.
- Never run test restores against production.

How to use it

  1. List what needs protecting with its real size (databases, user uploads, configuration).
  2. Agree with the business how much data can be lost and how long an outage can last.
  3. Deploy the scripts, force a failure to confirm the alert arrives, and schedule the first restore test.

Usage example

Data: 40 GB PostgreSQL 16 database and 120 GB of uploads · Server: Ubuntu 24.04 · Destination: S3-compatible object storage · RPO 1 h, RTO 4 h · systemd timers.

Sample output

1. Strategy

A 1-hour RPO rules out relying on a daily pg_dump: you need continuous WAL archiving (for example with pgBackRest) for point-in-time recovery. User uploads go through restic, which deduplicates and encrypts.

2. Schedule

WhatFrequencyTool
PostgreSQL WALContinuouspgBackRest archive-push
PostgreSQL fullWeekly, early SundaypgBackRest --type=full
PostgreSQL differentialDailypgBackRest --type=diff
User filesHourlyrestic

Duration of each run: [FILL IN] after the first one; measure it with systemctl status.

6. systemd units (files)

# /etc/systemd/system/backup-files.service
[Unit]
Description=Restic backup of user uploads
Wants=network-online.target
After=network-online.target

[Service]
Type=oneshot
EnvironmentFile=/etc/backup/restic.env
ExecStart=/usr/bin/flock -n /run/lock/backup-files.lock \
  /usr/bin/restic backup /srv/uploads --tag uploads
ExecStartPost=/usr/bin/restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 12 --prune
Nice=10
IOSchedulingClass=idle

# /etc/systemd/system/backup-files.timer
[Timer]
OnCalendar=hourly
RandomizedDelaySec=5m
Persistent=true

[Install]
WantedBy=timers.target

/srv/uploads is [FILL IN]. restic.env holds the repository and password with 600 permissions; if that password is lost the backup cannot be restored, so keep a copy off the server too…

Key facts

Category
Programming & development · DevOps
Output type
Code
Level
Intermediate
Designed for
ChatGPT, Claude, Gemini and Microsoft Copilot
Verified in
Pending editorial verification
Variables
Data and size, Server and OS, Backup destination, RPO and RTO and Scheduler
Language
English
Price
Free, no sign-up
Updated
Nov 7, 2026

Frequently asked questions

What do RPO and RTO mean?

RPO is the maximum amount of data you accept losing, measured in time (for example the last hour). RTO is the maximum time the service can take to come back after a disaster.

What is the 3-2-1 rule?

Keep at least three copies of your data, on two different types of media, with one copy off-site. Many guides now add an immutable or offline copy to defend against ransomware.

Is a daily pg_dump enough?

Only if you can afford to lose up to a day of data. For an RPO of minutes or hours you need continuous WAL or binlog archiving, which lets you restore to a specific moment.

What is this prompt for?

Design database and file backups that meet your RPO and RTO: the 3-2-1 rule, retention, encryption, scheduled scripts, alerts on failure and a tested restore procedure.

Which AI tools does it work with?

It is designed for ChatGPT, Claude, Gemini and Microsoft Copilot. We have not verified it in these tools yet, so results may vary between them.

How do I customize the prompt?

Click “Customize” and fill in the variables (Data and size, Server and OS, Backup destination, RPO and RTO and Scheduler). The text updates instantly and you can then copy it in one click. Values are stored only in your browser.

Do I need experience to use it?

It is intermediate: it helps to know the topic so you can provide good context and review the result critically.

Is this prompt free?

Yes. Every HomeCasa Prompts prompt is free, with no sign-up or subscription. You can also use them in professional projects.

Can I trust the AI output?

Treat it as a high-quality draft: always check data, figures and important claims before publishing or making decisions.

Related prompts