# Protected Storage with restic and rclone

https://www.gyrohosting.com/en/knowledgebase/article/restic-rclone-protected-storage

- **What you will learn**: How to connect restic and rclone to Protected Storage, make restic backups immutable with the bucket's default retention, and reach older versions with rclone.
- **Time**: 10 minutes

## 1. Connection details

| Setting | Value |
| --- | --- |
| Endpoint | `https://s3-kilit.gyrohosting.com` |
| Region | `tr-ist-1` |
| Addressing | Path style and virtual-host style |
| Request limit | About 1000 requests per second per IP address (up to 2000 for short bursts) |

This endpoint is different from standard Object Storage (`s3.gyrohosting.com`). Protected Storage access keys only work at this address.

> **Note**
> 
> If the limit is exceeded the server returns `503 SlowDown` with a `Retry-After` header. aws-cli, rclone, restic and S3 SDKs retry automatically after a short wait, so your job does not break. Normal backups never get near this limit. If you send many small files with high concurrency (for example rclone `--transfers 64` or many parallel Veeam jobs), keep concurrency around 16-32.

## 2. Immutable backups with restic

restic does not lock files by itself. The bucket enforces the lock: once you define a **default retention** on the bucket, every file restic uploads is locked for that period.

1. In the panel, create a bucket with **Turn on Object Lock (WORM)** ticked (for example enter `restic`, and the bucket becomes `restic-<code>`), then define a **Default retention** for it on the **Object Lock** page (for example COMPLIANCE, 14 days; use GOVERNANCE for your first try). The examples below use `firma-restic` as the bucket name; use your own. Details: [Object Lock guide](https://www.gyrohosting.com/bilgi-bankasi/makale/s3-nesne-kilidi-object-lock).
2. Set up the connection on your server:

```
export AWS_ACCESS_KEY_ID=<ACCESS_KEY>
export AWS_SECRET_ACCESS_KEY=<SECRET_KEY>
export AWS_DEFAULT_REGION=tr-ist-1
export RESTIC_REPOSITORY=s3:https://s3-kilit.gyrohosting.com/firma-restic/server1
export RESTIC_PASSWORD_FILE=/root/.restic-password
```

1. Create the repository and take the first backup:

```
restic init
restic backup /etc /var/www /root
```

1. When you clean up old snapshots with `restic forget --prune`, deletions only add a delete marker to the bucket. Locked files stay in place until the lock expires, and they still count against your plan's space. Once the lock ends, old versions are removed by the lifecycle rule (30 days by default).

> **Why is this safe?**
> 
> Even if an attacker takes over your server and your restic password and deletes the repository, the locked versions stay in place. You restore by going back to a point before the attack, either from the panel or with rclone `--s3-version-at`.

> **Tip**
> 
> Don't keep the restic password only on the server. Store it somewhere safe as well. Without it the backups cannot be opened.

## 3. With rclone

1. Add this to `~/.config/rclone/rclone.conf`:

```
[gyro-kilit]
type = s3
provider = Other
access_key_id = <ACCESS_KEY>
secret_access_key = <SECRET_KEY>
endpoint = https://s3-kilit.gyrohosting.com
region = tr-ist-1
force_path_style = true
no_check_bucket = true
```

> **Important**
> 
> Don't leave out `no_check_bucket = true`. Without it, rclone tries to re-create the bucket before sending large files (about 256 MB and up, multipart upload). Access keys cannot create buckets, so the upload stops with `CreateBucket 403 AccessDenied`. Buckets are created in the panel, so rclone does not need this check. If you don't use a config file, pass the same setting on the command line as `--s3-no-check-bucket`.

1. Copy and sync work with the standard commands:

```
rclone copy /var/backup gyro-kilit:firma-yedek/daily --progress
```

1. List old versions, with a timestamp added to each file name:

```
rclone ls gyro-kilit:firma-yedek/daily --s3-versions
```

1. Download the bucket as it was at a specific moment (to recover deleted or changed files):

```
rclone copy gyro-kilit:firma-yedek/daily ./restore --s3-version-at "2026-11-10 03:00:00"
```

> **Time zone**
> 
> rclone reads `--s3-version-at` in the **local time** of the machine running it. If your server uses UTC, or you aren't sure, give the time explicitly in UTC: `--s3-version-at "2026-11-10T00:00:00Z"` (03:00 Turkey time). A time given in the wrong zone can fall before the files were uploaded, and the list will look empty.

> **Careful**
> 
> `rclone sync` deletes files at the destination that are not in the source. In a versioned bucket this only adds a delete marker and can be undone, but it becomes permanent once the old-version retention period ends. Try `--dry-run` first to protect against running `sync` in the wrong direction.

## 4. Troubleshooting

| Symptom | Likely cause | What to do |
| --- | --- | --- |
| `restic init` "access denied" | The key has no write permission on the bucket, or the endpoint is wrong | Check the permission under **Access keys** and make sure the endpoint is `s3-kilit`. |
| Space doesn't shrink after `restic forget --prune` | Locked and old versions still take space | Normal. Space is freed when the lock and old-version retention periods end. |
| rclone `CreateBucket 403 AccessDenied` (`failed to prepare upload`) on a large file | rclone tries to create the bucket before a multipart upload | Add `no_check_bucket = true` to the config (or `--s3-no-check-bucket`). Section 3. |
| Occasional `503 SlowDown` | Per-IP request limit (about 1000/s) exceeded | The tools retry automatically. If it persists, lower concurrent transfers (rclone `--transfers 16`). |
| `--s3-version-at` returns an empty list | The time was read as local time | Give the time in UTC as `2026-11-10T00:00:00Z`. |
| rclone checksum error | Some newer client versions need an extra setting | Update rclone; for aws-cli try the environment variable `AWS_REQUEST_CHECKSUM_CALCULATION=when_required`. |

## 5. FAQ

**Should I choose Compliance or Governance for restic?**

Compliance is stronger against ransomware because nobody can bypass the lock. Start with Governance; once you're confident in the setup, switch to Compliance.

**Can I move my restic repository from standard Object Storage?**

Yes. Copy the repository folder to the new protected bucket with `rclone copy` and change the `RESTIC_REPOSITORY` address. Copied files are locked with the bucket's default retention.

**Does the bucket's default retention also lock restic's lock files?**

Yes, restic's temporary lock files are also kept as versions. They are tiny, so the space impact is negligible. restic removes them with a delete marker and keeps working.

## Next step

- **Recover a deleted file:** [Versioning guide](https://www.gyrohosting.com/bilgi-bankasi/makale/s3-versiyonlama-eski-surume-donme).
