Automatic backups with cron + ZFS (complete guide)

Questions about storage, backups, ZFS snapshots, replication and data protection for VPS and servers in Bulgaria.
rychy
Site Admin
Posts: 132
Joined: Tue Oct 20, 2026 10:45 am

Automatic backups with cron + ZFS (complete guide)

Post by rychy »

🇧🇬 Прочети на български

🤖 Automatic backups with ZFS + cron

In this guide we set up automatic ZFS snapshots

that are created on their own at fixed intervals.

📸 The snapshot command

Code: Select all

sudo zfs snapshot mypool/data@$(date +%Y-%m-%d-%H%M)

⏰ Adding it to cron

Open cron:

crontab -e

Add this line:

0 * * * * sudo zfs snapshot mypool/data@$(date +\%Y-\%m-\%d-\%H\%M)

👉 This makes a backup every hour

🗑️ Deleting old snapshots (very important)
sudo zfs list -t snapshot

Example of deleting one:

sudo zfs destroy mypool/data@snapshot-name

🔥 Automatic clean-up (optional)

You can add a second cron job:

0 3 * * * sudo zfs destroy $(zfs list -H -t snapshot -o name | head -n -10)

👉 It keeps the last 10 snapshots

✅ Advantages
fully automatic backups
no external tools
very fast recovery
ideal for VPS and storage servers
For more background on the technology see what ZFS storage is and why it matters.