# Back up to your own storage

A server's disk goes away when you destroy the server. This page shows a way to keep a copy of a folder in **your own bucket** that works on every account, today. You run a small helper script on the server over SSH. It needs nothing from us.

## How it works

- You download `gpu-backup.sh` onto your server and check its checksum.
- `setup` asks for your bucket details and saves them on the server. Any S3-compatible storage works: Amazon S3, Backblaze B2, Cloudflare R2, Wasabi, MinIO, Hetzner, DigitalOcean Spaces and others.
- `backup` copies a folder to `your-bucket/<name>/` and checks every file by checksum. `restore` copies it back.
- The helper uses the open-source tool [rclone](https://rclone.org). If rclone is missing on a Linux server, `setup` installs a pinned version for your user (no root needed) and verifies its SHA-256 checksum first.

## Your keys stay on your server

The bucket keys are written to `~/.config/gpu-backup/rclone.conf`, readable only by you (permission 600). They are never sent to us: the helper talks only to your storage provider. Use a key that can only reach this one bucket, and delete it at your provider when you no longer need it. `gpu-backup.sh forget` deletes the stored keys from the server.

Because the keys live on the server, anyone with access to your account on that server can read them. Do not share the server with people who should not see your bucket.

## Step by step

Connect with SSH (see [Connect over SSH](/docs/connect-ssh)), then:

```bash
# 1. Download and verify
curl -fsSLO https://apidly.com/downloads/gpu-backup.sh
curl -fsSL https://apidly.com/downloads/SHA256SUMS | grep ' gpu-backup\.sh$' | sha256sum -c - && chmod +x gpu-backup.sh

# 2. Save your bucket details (asks for endpoint, region, bucket, key and secret)
./gpu-backup.sh setup

# 3. Back up a folder
./gpu-backup.sh backup /workspace my-project
```

Other commands:

| Command | What it does |
|---|---|
| `./gpu-backup.sh list` | Lists the backups in the bucket. `list <name>` lists the files of one backup |
| `./gpu-backup.sh restore <name> <path>` | Copies a backup into a folder. Files with the same name are overwritten; nothing else is deleted |
| `./gpu-backup.sh schedule "0 3 * * *" <path> [name]` | Adds a crontab line for a backup every day at 03:00 |
| `./gpu-backup.sh unschedule [name]` | Removes the lines it added |
| `./gpu-backup.sh forget` | Deletes the stored keys and the scheduled lines. Your backups in the bucket stay |

Add `--dry-run` to any command to see what it would do without changing anything. Add `--exclude '*.tmp'` (repeatable) or `--exclude-common` to skip caches and temporary files. By default `backup` only adds and updates files in the bucket; add `--mirror` to also remove files there that you deleted on the server.

For a setup without questions (for example in a script), set `GPU_BACKUP_PROVIDER`, `GPU_BACKUP_ENDPOINT`, `GPU_BACKUP_REGION`, `GPU_BACKUP_BUCKET`, `GPU_BACKUP_ACCESS_KEY` and `GPU_BACKUP_SECRET_KEY` before running `setup`.

## Restore to a new server

1. Deploy a new server and connect over SSH.
2. Download the helper and run `setup` with the same bucket details.
3. Run `./gpu-backup.sh list` to see your backups, then `./gpu-backup.sh restore my-project /workspace`.

## Scheduling: only while the server runs

`schedule` uses the server's `cron`. Cron runs only while the server is running. A stopped or destroyed server makes no backups, and a run that was missed is not made up later. Schedule backups for times the server is normally on, and run one by hand before you destroy a server. If your server image has no cron, install it first or run `backup` yourself.

## Costs

Storing and downloading the backup is charged by your own storage provider, under your agreement with them, not by us. Check their prices for storage, requests and downloads (some charge for data leaving their service). There is no extra fee from us for using the helper.

## Limits

- Backups are copies of files, not images of a whole server. Install software again on the new server or use a [template](/docs/templates).
- The helper copies the files that exist when it runs; a file that is changing while it is copied may be copied in an inconsistent state. Stop the program that writes to a database before you back it up.
- Check a restore on a spare folder before you rely on it.

See also [Volumes and copies](/docs/storage) and [Moving data](/docs/data-movement).
