What are backups?
Backups in Zerobyte are scheduled jobs that automatically create encrypted snapshots of your volumes and store them in repositories. Each backup job connects a source (volume) to a destination (repository) and runs on a schedule defined by a cron expression. A backup job encapsulates:- What to back up - The volume (source data)
- Where to store it - The primary repository (and optional mirrors)
- When to run - Cron-based schedule
- What to keep - Retention policy
- What to include/exclude - File patterns and filters
- Who to notify - Alert destinations for success/failure
Why backup schedules matter
Manual backups are error-prone and easily forgotten. Scheduled backups ensure:Consistency
Backups run at predictable intervals (hourly, daily, weekly) without human intervention. You define the schedule once and Zerobyte handles execution.Automation
The entire backup lifecycle is automated:- Volume health verification
- Snapshot creation
- Retention policy application
- Mirror synchronization
- Notifications
Granular control
Each backup schedule can have unique:- Cron timing
- Inclusion/exclusion patterns
- Retention rules
- Mirror repositories
- Notification settings
Visibility
Every backup execution is tracked with:- Start and completion timestamps
- Success/warning/error status
- Detailed progress events (files processed, bytes transferred)
- Error messages for failures
Backup lifecycle
Each scheduled backup execution follows this flow:Validation phase
Before backup execution, Zerobyte validates:- Schedule enabled - Disabled schedules are skipped (unless manually triggered)
- Not already running - Prevents duplicate executions
- Volume exists - Schedule references a valid volume
- Repository exists - Schedule references a valid repository
- Volume mounted - Source must be accessible
Execution phase
During execution:- Lock acquisition - Repository receives a shared lock (allows concurrent backups, blocks maintenance)
- Restic invocation -
restic backupruns with configured options - Progress streaming - Real-time progress events via server-sent events (SSE)
- Status tracking -
lastBackupStatusupdated toin_progress
Post-backup phase
After successful backup:- Retention application -
restic forgetremoves old snapshots based on policy - Mirror synchronization - Snapshots copied to mirror repositories
- Cache invalidation - Repository caches cleared to reflect new snapshots
- Next run calculation -
nextBackupAtcomputed from cron expression - Notifications sent - Success/warning/failure alerts delivered
Cron expressions
Backup schedules use cron expressions to define when backups run. Zerobyte uses standard cron syntax:Common patterns
Every hour
Every hour
Daily at 2 AM
Daily at 2 AM
Every 6 hours
Every 6 hours
Weekdays at 6 PM
Weekdays at 6 PM
Weekly on Sunday
Weekly on Sunday
Monthly on the 1st
Monthly on the 1st
Every 15 minutes
Every 15 minutes
Next run calculation
Zerobyte automatically calculatesnextBackupAt using the cron expression and the system timezone. This value:
- Updates after each backup completes
- Accounts for the server’s timezone
- Determines when the scheduler triggers the next execution
Inclusion and exclusion patterns
Fine-tune what gets backed up using include and exclude patterns.Exclude patterns
Specify paths or glob patterns to skip during backup:- Paths starting with
/are relative to the volume root - Paths without
/are matched anywhere in the tree - Glob patterns supported:
*,**,?,[...] - Prefix with
!to negate (include despite other exclusions)
- Temporary files:
*.tmp,/tmp/** - Caches:
/var/cache/**,node_modules/**,.cache/** - Logs:
*.log,/var/log/** - OS files:
.DS_Store,Thumbs.db,desktop.ini
Include patterns
Explicitly specify what to back up (everything else is excluded):Exclude if present
Skip directories containing specific marker files:.nobackup in a directory, that entire directory (and subdirectories) are excluded.
Use cases:
- Let developers mark cache directories with
.nobackup - Exclude build artifacts by placing
SKIP_BACKUP.txtintarget/ordist/
One file system
TheoneFileSystem flag restricts backups to a single filesystem:
- Mount points encountered during traversal are not crossed
- Prevents backing up accidentally mounted filesystems
- Useful for NFS volumes where subdirectories might be remote mounts
How backups work in Zerobyte
Scheduler
Zerobyte runs a background scheduler that:- Polls
backupSchedulesTableevery minute - Finds schedules where
nextBackupAt <= nowandenabled = true - Calls
executeBackup()for each due schedule - Continues running even if individual backups fail
Backup execution
TheexecuteBackup() function orchestrates the backup:
Progress tracking
During backup, Restic emits progress events that Zerobyte streams to the UI:getBackupProgress(scheduleId) for the frontend to display real-time status.
Restic tags
Every snapshot created by a backup schedule is tagged with the schedule’sshortId. This enables:
- Filtering snapshots by backup schedule
- Targeted retention (forget only affects snapshots with the schedule’s tag)
- Restore history (see which schedule created each snapshot)
Retention policies
See Retention Policies for a detailed explanation of how snapshots are pruned based on age and count.Mirror repositories
Mirror repositories provide redundancy by copying snapshots to additional storage locations.How mirrors work
- Primary backup completes successfully to the main repository
- For each enabled mirror:
- Acquire locks on source and mirror repositories
- Run
restic copyto transfer snapshots matching the schedule’s tag - Apply retention policy to the mirror (if configured)
- Update mirror status and timestamps
Mirror compatibility
Not all repository backends are compatible for mirroring. Zerobyte checks compatibility before allowing mirror configuration: Compatible pairs:- Local ↔ Local
- S3-compatible ↔ S3-compatible (S3, R2, MinIO, etc.)
- Any ↔ REST server
- Rclone ↔ Rclone (if backends match)
- S3 ↔ Azure (different authentication mechanisms)
- GCS ↔ SFTP (protocol mismatch)
Compatibility is determined by whether Restic can authenticate to both repositories in a single copy operation.
Mirror status tracking
Each mirror tracks:lastCopyAt- When the last copy operation ranlastCopyStatus- “success”, “error”, or “in_progress”lastCopyError- Error message if copy failed
Backup status states
Warning
Backup completed but Restic exited with a non-zero code. Common causes:
- Some files were unreadable (permission errors)
- File changed during backup (common for active databases)
Error
Backup failed to complete. Possible causes:
- Volume unmounted during backup
- Repository unreachable
- Insufficient storage space
- Network timeout
lastBackupError contains the error message.Manual backups
Backups can be triggered manually via the UI or API, bypassing the schedule:- Run immediately regardless of
nextBackupAt - Ignore the
enabledflag (run even if schedule is disabled) - Update
lastBackupAtandnextBackupAtas normal - Count toward the retention policy
Stopping backups
In-progress backups can be stopped via:- Aborts the Restic process via signal
- Releases the repository lock
- Sets status to “warning” with error “Backup was stopped by user”
- May leave partial snapshot data (cleaned up by next prune/doctor)
Database schema
Backup schedules are stored inbackup_schedules_table:
Best practices
Schedule backups during off-peak hours
Schedule backups during off-peak hours
Run resource-intensive backups when system load is low:
- Databases: After business hours (e.g.,
0 2 * * *) - File servers: Overnight or early morning
- Production systems: Consider read-only hours or maintenance windows
Use specific exclusion patterns
Use specific exclusion patterns
Exclude temporary and cache data to reduce:
- Backup time
- Storage costs
- Repository size
Test restore procedures
Test restore procedures
Regularly verify backups are restorable:
- Pick a random snapshot
- Restore to a test location
- Verify data integrity
- Document recovery time
Monitor backup health
Monitor backup health
Set up alerts for:
- Backups that haven’t completed in 24 hours
- Consistent backup failures (3+ in a row)
- Sudden changes in backup size or duration
Combine with retention policies
Combine with retention policies
Don’t just create backups — define how long to keep them:
- Critical data: Keep daily for 30 days, weekly for 1 year
- Development data: Keep last 7 days only
- Archives: Keep yearly snapshots indefinitely
Use mirrors for critical data
Use mirrors for critical data
Configure mirror repositories to protect against:
- Cloud provider outages
- Regional disasters
- Accidental repository deletion
- Geographic regions
- Cloud providers
- Storage tiers (hot primary, cold mirror)
Next steps
Retention policies
Learn how to configure snapshot retention rules
Restoring data
Recover files and directories from snapshots
Backup job setup
Step-by-step guide to creating backup schedules
Notifications
Configure alerts for backup success and failure
