📨 Copy Job
Copy jobs replicate snapshots from one repository to another. This is useful for creating off-site backups or maintaining multiple backup copies.
Configuration Structure
jobs:
- type: copy
name: string # Required: Unique job name
from: string # Required: Source repository name
to: string # Required: Target repository name
cron: string # Optional: Cron expression
healthcheck_url: string # Optional: Job-specific healthcheck URL
options: # Optional: Restic copy options
key: value
hooks: # Optional: Lifecycle hooks
before: []string
success: []string
failure: []stringRequired Fields
type
Must be "copy".
name
Unique identifier for the job. Used in logs and when selecting specific jobs.
name: offsite-copy
name: documents-to-remote
name: backup-replicationfrom
Name of the source repository (must be defined in repositories section).
from: local-repo
from: primary-backupto
Name of the target repository (must be defined in repositories section).
to: remote-repo
to: secondary-backupOptional Fields
cron
Cron expression for scheduling automated copy operations.
Format: minute hour day month weekday
Examples:
cron: "0 3 * * *" # Daily at 3:00 AM (after backup completes)
cron: "0 */12 * * *" # Every 12 hours
cron: "0 4 * * 0" # Weekly on Sunday at 4:00 AMSee Cron Command for more details.
healthcheck_url
Override global healthcheck URL for this specific job.
healthcheck_url: https://hc-ping.com/uuid-for-copy/copy-jobSee Healthchecks for more details.
Options
The options field accepts any restic copy option. Common options:
Filter by Tags
Copy only snapshots with specific tags:
options:
tag:
- important
- documents
- dailyFilter by Hostname
Copy only snapshots from specific host:
options:
host: my-serverFilter by Paths
Copy only snapshots containing specific paths:
options:
path: /home/user/DocumentsSee: Restic Copy Documentation (opens in a new tab) for complete list of options.
Hooks
Execute custom commands at different stages:
hooks:
before:
- echo "Starting copy operation: $CRESTIC_JOB_NAME"
success:
- echo "Copy completed successfully: $CRESTIC_JOB_NAME"
failure:
- echo "Copy failed: $CRESTIC_JOB_NAME - $CRESTIC_ERROR" >&2Environment variables available in hooks:
CRESTIC_JOB_NAME- Name of the jobCRESTIC_EXIT_CODE- Exit code of the operationCRESTIC_ERROR- Error message (only in failure hooks)
See Hooks for more details.
Complete Example
jobs:
- type: copy
name: documents-copy-to-remote
from: local-repo
to: remote-repo
cron: "0 3 * * *"
healthcheck_url: https://hc-ping.com/uuid/copy-job
options:
tag:
- documents
- important
host: my-server
hooks:
before:
- echo "Starting copy: $CRESTIC_JOB_NAME"
success:
- echo "Copy completed: $CRESTIC_JOB_NAME"
failure:
- echo "Copy failed: $CRESTIC_JOB_NAME - $CRESTIC_ERROR" >&2Running Copy Jobs
Run Specific Job
crestic backup --job offsite-copyNote: Copy jobs are executed using the backup command, not a separate copy command.
Run Multiple Jobs
crestic backup --job offsite-copy,another-copyRun All Jobs
crestic backup --allWhat Happens During Copy
The copy operation:
- Sends start ping to healthcheck service (if configured)
- Runs 'before' hooks (if configured)
- Copies snapshots from source to target repository
- Runs 'success' or 'failure' hooks based on outcome
- Sends success/failure ping to healthcheck service
Error Handling
When running multiple jobs, each job executes independently. If one job fails:
- The error is logged
- Execution continues with the next job
- Other jobs will still run
- At the end, all errors are collected and returned as a combined error message
This ensures that a failure in one job doesn't prevent other jobs from completing. Each job's success or failure is tracked separately, and healthcheck notifications are sent for each job individually.
See Also
- Backup Job - Back up directories to repositories
- Configuration Guide - Complete configuration reference
- Repositories - Repository setup
- Hooks - Lifecycle hooks
- Healthchecks - Monitoring integration