> ## Documentation Index
> Fetch the complete documentation index at: https://help.freakhosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Back Up to S3 or Google Drive with rclone

> Back up a Linux server to S3, Google Drive or other cloud storage with rclone: add a remote with rclone config, encrypt it with crypt and run rclone sync daily.

To back up a Linux server to S3 or Google Drive with rclone, install rclone, run `rclone config` to add your storage as a **remote**, optionally wrap it in an encrypted **crypt** remote, then copy your folders with `rclone sync /var/www secret:www --backup-dir secret:old/2026-11-04`. Test with `--dry-run` first and schedule it with cron.

| Difficulty | Time | Works on | Needs |
| - | - | - | - |
| Intermediate | 20–30 minutes | Any Linux distribution | sudo, a cloud storage account (S3-compatible, Google Drive, Backblaze B2 and others) |

## Before you start

* [Connect with SSH](https://help.freakhosting.com/portals/other/how-to-connect-to-a-linux-server-with-ssh.md). Commands use `sudo`; root users can leave it out.
* Have your storage details ready: for S3-compatible storage an **access key**, **secret key**, **endpoint** and **bucket**; for Google Drive a Google account and a computer with a web browser.
* A **remote** is rclone's name for one storage location, for example `s3backup:` or `gdrive:`.

## How to install rclone

The rclone project notes that distribution packages are often out of date, and recommends its install script:

```bash theme={null}
sudo -v ; curl https://rclone.org/install.sh | sudo bash
rclone version
```

You can also use your package manager (`sudo apt install rclone` on Ubuntu / Debian). Ubuntu 24.04 ships rclone 1.60, which is older but works for the commands on this page.

## How to add a cloud storage remote

Run the backup as root, so configure rclone as root too. The configuration is saved in `/root/.config/rclone/rclone.conf`.

```bash theme={null}
sudo rclone config
```

Choose `n` (new remote), enter a name, then pick the storage type.

> [tab] S3-compatible storage
>
> Choose **Amazon S3 Compliant Storage Providers**, then your provider (or **Other**). Enter the access key, secret key and endpoint. The finished section in `rclone.conf` looks like this:
>
> ```ini theme={null}
> [s3backup]
> type = s3
> provider = Other
> env_auth = false
> access_key_id = EXAMPLEKEYID
> secret_access_key = EXAMPLESECRET
> endpoint = https://s3.example.com
> ```
>
> Test it by listing your buckets:
>
> ```bash theme={null}
> sudo rclone lsd s3backup:
> ```

> [tab] Google Drive (headless server)
>
> Choose **Google Drive**. When rclone asks `Use web browser to automatically authenticate rclone with remote?`, answer `n`, because the server has no browser. On your own computer, install rclone and run:
>
> ```bash theme={null}
> rclone authorize "drive"
> ```
>
> Sign in in the browser that opens, copy the token rclone prints, and paste it into the `config_token>` prompt on the server. Then test it:
>
> ```bash theme={null}
> sudo rclone lsd gdrive:
> ```

## How to encrypt backups with an rclone crypt remote

A **crypt** remote encrypts file contents and file names before they leave your server. It sits on top of a normal remote.

**1. Create the crypt remote**

Run `sudo rclone config`, choose `n`, name it `secret`, and pick **Encrypt/Decrypt a remote**. For the remote to encrypt, enter a folder on your storage, for example `s3backup:my-bucket/server1`.

**2. Choose passwords**

Let rclone generate a password or enter your own, plus the optional second password (salt). **Store both outside the server**, for example in a password manager.

**3. Always use the crypt remote**

Upload and download through `secret:`. Files written straight to `s3backup:my-bucket/server1` are not encrypted.

> [!WARNING]
>
> If you lose the crypt passwords and the `rclone.conf` file, nobody can decrypt your backups, including us. Keep a copy of the passwords somewhere other than the server you are backing up.

## Should I use rclone copy or rclone sync?

| Command | What happens on the destination |
| - | - |
| `rclone copy` | Adds new and changed files. Never deletes anything |
| `rclone sync` | Makes the destination identical to the source, **including deleting files** |
| `rclone sync ... --backup-dir` | Like sync, but files that would be deleted or overwritten are moved into the backup folder instead |

For backups, use `sync` with `--backup-dir`, so deleted and changed files are kept for a while.

## How to run an rclone backup

**1. Dry run**

```bash theme={null}
sudo rclone sync /var/www secret:www \
  --backup-dir secret:old/$(date +%F)/www \
  --exclude 'cache/**' --dry-run
```

rclone lists what it would copy and delete, without changing anything.

**2. Run the backup**

```bash theme={null}
sudo rclone sync /var/www secret:www \
  --backup-dir secret:old/$(date +%F)/www \
  --exclude 'cache/**' --log-file /var/log/rclone-backup.log --log-level INFO
```

**3. Check the result**

```bash theme={null}
sudo rclone check /var/www secret:www --exclude 'cache/**'
```

Success ends with `0 differences found`.

> [!WARNING]
>
> `rclone sync` deletes files on the destination that are not in the source. If you get the source and destination the wrong way round, it deletes your live files. Run `--dry-run` (or `-i` to confirm each change) whenever you change the command. `--backup-dir` must be on the same remote as the destination and must not overlap the destination folder.

Back up databases by dumping them to a file first, then include that file. See [back up MySQL databases](https://help.freakhosting.com/portals/other/how-to-back-up-and-restore-mysql-databases.md).

## How to run rclone backups on a schedule

Put the sync commands in `/usr/local/bin/rclone-backup.sh`, then `sudo chmod 700 /usr/local/bin/rclone-backup.sh` and add it to root's crontab with `sudo crontab -e`:

```bash theme={null}
0 4 * * * /usr/local/bin/rclone-backup.sh
```

Add `--bwlimit 20M` if the upload slows your server; it limits rclone to 20 MiB/s (bytes, not bits). See [schedule tasks with cron](https://help.freakhosting.com/portals/other/how-to-schedule-tasks-with-cron.md).

## How to restore files with rclone

Copy from the remote to a temporary folder, check the files, then move them into place:

```bash theme={null}
sudo rclone copy secret:www/example.com /tmp/restore/example.com
```

Older versions of changed or deleted files are under `secret:old/<date>/`.

## Frequently asked questions

### Does rclone keep old versions of files?

Not by itself. `rclone sync` keeps only the latest copy unless you add `--backup-dir`. For proper snapshots with deduplication, use [restic](https://help.freakhosting.com/portals/other/how-to-make-encrypted-backups-with-restic.md), which can also store its repository through rclone.

### Where is the rclone config file?

Run `rclone config file`. On Linux it is normally `~/.config/rclone/rclone.conf`, so `/root/.config/rclone/rclone.conf` for root. It contains your storage keys: keep it readable only by root.

### Can I use Google Drive on a server without a browser?

Yes. Answer `n` to the browser question in `rclone config`, run `rclone authorize "drive"` on a computer with a browser, and paste the token back on the server.

### Why does rclone sync need permission to create buckets?

On S3, rclone checks or creates the bucket. If your key cannot create buckets, create the bucket yourself and add `--s3-no-check-bucket`.

## Related guides

> [card] [VPS and dedicated server guides](https://help.freakhosting.com/portals/other/vps-and-dedicated-server-guides.md)
>
> Every guide in this section.

> [card] [Back up a Linux server](https://help.freakhosting.com/portals/other/how-to-back-up-a-linux-server.md)
>
> What to back up and which tool to use.

> [card] [Encrypted backups with restic](https://help.freakhosting.com/portals/other/how-to-make-encrypted-backups-with-restic.md)
>
> Versioned, deduplicated backups.

> [card] [Back up with rsync](https://help.freakhosting.com/portals/other/how-to-back-up-files-with-rsync.md)
>
> Copy to another server over SSH.

> [card] [Schedule tasks with cron](https://help.freakhosting.com/portals/other/how-to-schedule-tasks-with-cron.md)
>
> Run backups automatically.

***

> [!NOTE]
>
> **Checked against the official [rclone documentation](https://rclone.org/docs/)** on 4 November 2026; `rclone config create`, `copy`, `sync --dry-run`, `--backup-dir`, `check` and a crypt remote tested on Ubuntu 24.04 LTS (rclone 1.60.1) against local storage. Commands can differ on other distributions or releases.

> [!NOTE]
>
> ### Need Extra Help?
>
> If you encounter any issues, our support team is ready to assist:
>
> * **Live Chat:** Quick assistance via our website.
> * **Support Ticket:** [Open a Ticket](https://freakhosting.com/clientarea/submitticket.php)
> * **Discord:** [Join our Community](https://discord.gg/freakhosting)
> * **Email:** [support@freakhosting.com](mailto:support@freakhosting.com)

> [!TIP]
>
> ### Save on Your Hosting
>
> Ready to upgrade your hosting? Use code **KB20** at checkout for **20% off** your first order!

***

**Last Updated:** November 2026


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.