autorestic Documentation
repository·master·Indexed 23 days ago
https://github.com/cupcakearmy/autoresticA configuration-driven CLI wrapper for the restic backup tool. autorestic simplifies the management of complex backup workflows, multiple data sources, and backup destinations using YAML configuration files. It provides commands for backups, restores, snapshot pruning (forget), configuration verification, and automated cron-based backups.
What's inside autorestic
- autorestic is a high-level CLI utility designed as a wrapper around restic. It simplifies the management of complex backup workflows by allowing you to define multiple backup locations and configurations using YAML files instead of managing long, complex restic CLI commands. It is particularly useful when you need to manage backups for many different locations across multiple backends.
Overview of Autorestic
masterAutorestic is a configuration-driven CLI wrapper for restic. It is designed to simplify the management of complex backup workflows, especially when dealing with multiple data sources and multiple backup destinations. Instead of managing long and complexresticCLI commands, you define your backup logic in YAML configuration files.Community-driven software for autorestic
masterThe following community-driven projects are available to help integrate or deploy
autorestic. Note that these are not officially affiliated with theautoresticproject:- SystemD Units: For running autorestic as a systemd service.
- Docker Image: For running autorestic within a containerized environment.
- Ansible Roles: For automating autorestic configuration and deployment via Ansible.
Key features of autorestic
masterautorestic provides several features to enhance the restic backup experience:
- YAML Configuration: Manage all settings via YAML files instead of complex CLI arguments.
- Incremental Backups: Uses restic's incremental capabilities to ensure minimal space is used.
- Multi-Backend Support: Back up data to multiple different storage backends.
- Snapshot Management: Define snapshot policies and pruning rules.
- Security: All backups are fully encrypted.
- Automation Hooks: Execute custom commands before or after a backup runs.
- Exclusions: Support for exclude patterns and specific files.
- Scheduled Backups: Compatible with cron jobs for automatic execution.
- Docker Integration: Ability to backup and restore Docker volumes.
- Shell Completions: Generated completions available for
bash,zsh,fish, andpowershell.
Back up a specific backend for a location
masterWhen specifying a location via the
-lor--locationflag, you can use thelocation@backendsyntax to target a specific backend associated with that location instead of the default one.autorestic backup -l location@backendUnderstand the Autorestic hook execution flow
masterThe execution order of hooks follows this lifecycle:
prevalidatehook- Check backup location (validates
toandfrom) beforehook- Run backup
afterhook- Result-based execution:
successhook (if no errors found)failurehook (if at least one error encountered)
Note on failures: If
prevalidateorbeforehooks encounter errors, the backup andafterhooks are skipped, and only thefailurehook runs.Define backup locations in autorestic
masterIn autorestic, a location represents the input to the backup process, typically a folder or a set of folders. Locations are defined under the
locationskey in your configuration file.Important Requirement: Location names MUST be in lower case.
A single location can be configured to back up to multiple backends, ensuring data redundancy across different servers.
version: 2 locations: my-location-name: from: path/to/backup to: - name-of-backend - also-backup-to-this-backendUnderstand option priority in autorestic
masterWhen configuring
resticflags,autoresticresolves conflicts using a hierarchical priority system. If the same flag is defined in multiple places, the more specific definition wins.The order of priority (from highest to lowest) is:
- Location options (highest priority)
- Backend options
- Global options (lowest priority)
How backup referencing and tagging works
masterIn version
1.5, Autorestic transitioned from referencing backups by their file path to using native Restic tags.Consequences:
- The
restoreandprunecommands will no longer automatically recognize or include backups created before this change (pre-1.5). - To use old backups with the new system, you must manually tag them.
To manually tag an old backup so it can be referenced by name, use the
autorestic execcommand with the--tag --addflags. Note that this specific command format is intended for scenarios where you have only one location.autorestic exec -va -- tag --add ar:location:LOCATION_NAME # Only if you have only one location- The
Understand environment variable precedence
masterWhen configuration values are defined in multiple places,
autoresticresolves them using the following order of precedence (highest to lowest):- Env Variables (System environment variables)
- Env File (
.autorestic.env) - Config file (
.autorestic.yaml)
Configure Backends in autorestic
masterBackends define the output locations for your backup process. Every backup configuration must include at least one backend.
Important: Backend names must be written in lower case.
version: 2 backends: name-of-backend: type: local path: /data/my/backupsReuse configuration snippets using YAML aliases
masterTo avoid repetition in advanced configurations, you can use YAML aliases. Define reusable snippets under the global
extraskey in your.autorestic.ymlfile. You can then inject these snippets intolocationsusing the&(anchor) and*(alias) syntax, or the<<(merge) operator.Common use cases include sharing
hooks(prevalidate, before, after) oroptions: forgetpolicies across multiple locations.version: 2 extras: hooks: &foo prevalidate: - echo "Wake up!" before: - echo "Hello" after: - echo "kthxbye" policies: &bar keep-daily: 14 keep-weekly: 52 backends: # ... locations: a: from: /data/a to: some hooks: <<: *foo options: forget: <<: *bar b: from: data/b to: some hooks: <<: *foo options: forget: <<: *bar