Introduce comprehensive recipes for Restic-based S3 backups. Covers installation, S3 repository configuration, automated backup job creation, and restoration of files.
2.2 KiB
2.2 KiB
Configure Restic S3 Repository
This recipe configures an encrypted Restic repository stored in an S3-compatible object storage.
Supported Providers
Restic supports any S3-compatible storage provider, including:
- MinIO
- Amazon S3
- Cloudflare R2
- Oracle Cloud Object Storage
Create Environment File
sudo nano /etc/restic.env
Example:
export AWS_DEFAULT_REGION=YOUR_BUCKET_REGION_OR_AUTO
export AWS_ACCESS_KEY_ID=YOUR_ACCESS_KEY
export AWS_SECRET_ACCESS_KEY=YOUR_SECRET_KEY
export RESTIC_PASSWORD=CHANGE_ME
export RESTIC_REPOSITORY=s3:https://<S3_ENDPOINT>/<BUCKET>/restic/<PREFIX>
Replace:
<S3_ENDPOINT>with your provider endpoint.<BUCKET>with your bucket name.<PREFIX>with a prefix for backups (e.g. machine name)
Protect the file:
sudo chmod 600 /etc/restic.env
sudo chown root:root /etc/restic.env
Common Endpoint Examples
| Provider | Endpoint |
|---|---|
| MinIO | minio.example.com |
| Amazon S3 | s3.amazonaws.com |
| Cloudflare R2 | <ACCOUNT_ID>.r2.cloudflarestorage.com |
| Oracle Cloud | <NAMESPACE>.compat.objectstorage.<REGION>.oraclecloud.com |
Example Configurations
Cloudflare R2:
RESTIC_REPOSITORY=s3:https://xxxxxxxx.r2.cloudflarestorage.com/backups/restic
Oracle Cloud:
RESTIC_REPOSITORY=s3:https://mynamespace.compat.objectstorage.sa-saopaulo-1.oraclecloud.com/backups/restic
Load Environment
source <(sudo cat /etc/restic.env)
Initialize Repository
restic init
Expected output:
created restic repository
If the repository already exists:
repository master key and config already initialized
Verify Repository
restic snapshots
Expected output:
no snapshots found
Troubleshooting
Repository already initialized
Expected if repository exists.
Wrong password
Verify the value of:
echo $RESTIC_PASSWORD