LinuxCommandLibrary

restic

Backup and restore data securely

TLDR

Initialize a backup repository in the specified local directory

$ restic init --repo [path/to/repository]
copy

Backup a directory to the repository
$ restic --repo [path/to/repository] backup [path/to/directory]
copy

Show backup snapshots currently stored in the repository
$ restic --repo [path/to/repository] snapshots
copy

Restore a specific backup snapshot to a target directory
$ restic --repo [path/to/repository] restore [latest|snapshot_id] --target [path/to/target]
copy

Restore a specific path from a specific backup to a target directory
$ restic --repo [path/to/repository] restore [snapshot_id] --target [path/to/target] --include [path/to/restore]
copy

Clean up the repository and keep only the most recent snapshot of each unique backup
$ restic forget --keep-last 1 --prune
copy

SYNOPSIS

restic [flags] command [command flags] [arguments]

PARAMETERS

--cache-dir directory
    Set the cache directory. Defaults to ~/.cache/restic or the value of $RESTIC_CACHE_DIR.

--cleanup-cache
    Removes all contents of the cache directory.

--compression mode
    Set the compression mode (auto, off, max). Defaults to auto.

--exclude pattern
    Exclude files matching the given pattern (can be specified multiple times).

--exclude-file filename
    Read exclude patterns from the given file.

--host hostname
    Set the hostname for the backup.

--json
    Output in JSON format.

--limit-concurrent-uploaders n
    Limit the number of concurrent uploaders to n.

--no-cache
    Disable the use of cache.

--password password
    Use the given password for the repository.
Use environment variables or a password file for security best practices.

--password-file filename
    Read the password from the given file.
Use environment variables or a password file for security best practices.

--progress
    Show progress during backup and restore operations.

--repo repository
    The location of the restic repository. Can be a local path or a URL.

--repository-file filename
    Read the repository location from the given file.

--tag tag
    Adds a tag to the snapshot. (can be specified multiple times)

--verbose
    Be more verbose.

DESCRIPTION

restic is a modern backup program designed to be easy to use, fast, and space-efficient. It utilizes data deduplication to minimize storage space, ensuring that only unique data is stored. This makes restic particularly well-suited for backing up large filesystems or systems with frequent data changes. restic encrypts all data by default using authenticated encryption (AES-256-GCM), providing strong security for your backups both in transit and at rest. It supports various storage backends including local disks, network storage (via SFTP, HTTP), and cloud services like AWS S3, Google Cloud Storage, Azure Blob Storage, and others. restic's design emphasizes reliability and data integrity, incorporating features like snapshots, integrity checks and a forget command to manage data retention policies. It is commonly used for personal backups, server backups, and even for backing up virtual machine images.

CAVEATS

Security: storing the password directly in the command is not recommended, use environment variables or password files.
Permissions: ensure restic has appropriate permissions to access files and directories being backed up.
Backends: performance can vary significantly depending on the chosen storage backend.

REPOSITORIES

A restic repository is a storage location that holds all backup data, including snapshots, data blobs, and metadata. It is essential to initialize a repository before performing any backups.
restic init is used to create the repository.

SNAPSHOTS

Snapshots represent a point-in-time backup of the data. They are created using the restic backup command. Each snapshot contains metadata about the backup, such as the hostname, timestamp, and tags. Snapshots can be listed, inspected, and restored.

RETENTION POLICIES

restic allows defining retention policies using the restic forget command to automatically remove old snapshots based on various criteria such as age, number of snapshots to keep per day/week/month/year.

HISTORY

restic development started in 2014 with the aim of creating a secure, fast, and efficient backup solution. It was designed to address limitations of existing backup tools, such as slow performance, lack of built-in encryption, and complex configuration. restic has gained popularity due to its ease of use, robust feature set, and wide range of supported backends. Active development continues with frequent releases addressing bugs, adding new features, and improving performance.

SEE ALSO

tar(1), rsync(1)

Copied to clipboard