Introduce comprehensive recipes for Restic-based S3 backups. Covers installation, S3 repository configuration, automated backup job creation, and restoration of files.
116 lines
2.2 KiB
Markdown
116 lines
2.2 KiB
Markdown
# 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
|
|
|
|
```bash
|
|
sudo nano /etc/restic.env
|
|
```
|
|
|
|
Example:
|
|
|
|
```bash
|
|
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:
|
|
|
|
```bash
|
|
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:
|
|
|
|
```bash
|
|
RESTIC_REPOSITORY=s3:https://xxxxxxxx.r2.cloudflarestorage.com/backups/restic
|
|
```
|
|
|
|
Oracle Cloud:
|
|
|
|
```bash
|
|
RESTIC_REPOSITORY=s3:https://mynamespace.compat.objectstorage.sa-saopaulo-1.oraclecloud.com/backups/restic
|
|
```
|
|
|
|
## Load Environment
|
|
|
|
```bash
|
|
source <(sudo cat /etc/restic.env)
|
|
```
|
|
|
|
## Initialize Repository
|
|
|
|
```bash
|
|
restic init
|
|
```
|
|
|
|
Expected output:
|
|
|
|
```text
|
|
created restic repository
|
|
```
|
|
|
|
If the repository already exists:
|
|
|
|
```text
|
|
repository master key and config already initialized
|
|
```
|
|
|
|
## Verify Repository
|
|
|
|
```bash
|
|
restic snapshots
|
|
```
|
|
|
|
Expected output:
|
|
|
|
```text
|
|
no snapshots found
|
|
```
|
|
|
|
## Troubleshooting
|
|
|
|
### Repository already initialized
|
|
|
|
Expected if repository exists.
|
|
|
|
### Wrong password
|
|
|
|
Verify the value of:
|
|
|
|
```bash
|
|
echo $RESTIC_PASSWORD
|
|
```
|