# Linux Backups with Restic and S3

- Author: Kyle Murphy
- Posted: 31 May 2022 (updated on 7 Oct 2026)

![Tux the penguin, the Restic mascot and an S3 storage icon joined by plus signs, above the words Linux Backups with Restic & S3.](https://www.customcodeit.com.au/_astro/backups-with-restic.BWvrcyJz_ZCr4HF.webp)

Fast, secure, low-friction backups are something we should all want if we work with files we don't want to lose. I think we're spoilt for choice when it comes to backup tools on Windows. Linux has solutions too, but the barrier to entry seems higher.

After some research and trying different tools, here's what I've found that works for my workflow.

## Restic

After trying a few different approaches and failing to find something I felt confident with, I stumbled upon [Restic](https://restic.net/). The spiel on their homepage sums it up quite well: it's cross-platform, fairly easy to use, has good documentation, creates secure backups, and makes backups easy to restore and verify. Best of all, it's free.

## Linode

Restic has a long list of options for where your backups (called repositories) are stored. I'm using S3-compatible [Linode Object Storage](https://www.linode.com/products/object-storage/). Linode is a popular choice for cloud computing, so you might already use it for other projects. Their Object Storage is quite affordable and predictable, but this guide should work with any S3-compatible storage, including Amazon S3 and MinIO.

## Install Restic

Install Restic on your PC first. The [Restic documentation](https://restic.readthedocs.io/en/stable/) has installation instructions for your distro.

Once it's installed, run this command to check it worked:

```bash
restic version
```

In my case, I am using version 0.12.1.

## Create a Restic repository

Run the following commands to set up your Restic repository:

```bash
export AWS_ACCESS_KEY_ID=<LINODE_ACCESS_KEY_ID>
export AWS_SECRET_ACCESS_KEY=<LINODE_SECRET_ACCESS_KEY>
restic -r s3:eu-central-1.linodeobjects.com/yourbucketname init
```

You will then be prompted to enter a password to protect your repository. Pick a good one, because it is used to encrypt your backups.

## Create a backup

Before we create a backup, we want to check which files are being included and how large the backup will be. Restic 0.13.0 and later can do a dry run to work this out:

```bash
restic -r s3:eu-central-1.linodeobjects.com/yourbucketname backup /backup/path/ --dry-run -vv
```

If you're happy with the result, run the command again without the dry-run flag:

```bash
restic -r s3:eu-central-1.linodeobjects.com/yourbucketname backup /backup/path/ -vv
```

## Exclude files

Restic can exclude files from a backup. If you're a software developer, for example, you won't want to include directories like `node_modules`, `vendor`, `Debug` or `Bin`. To avoid them, create a file listing what to leave out. Here's a simple example called `exclude.conf`:

```text
**/node_modules
**/.env
**/vendor
Downloads
```

You can check this file against your backup path with the following command:

```bash
du -ch --exclude-from=/path/to/exclude.conf /backup/path
```

When you're happy with the result, add it to your backup command:

```bash
restic -r s3:eu-central-1.linodeobjects.com/yourbucketname backup /backup/path/ --exclude-file=/path/to/exclude.conf -vv
```

## Restore

Restoring from a backup is simple too. The [existing documentation](https://restic.readthedocs.io/en/stable/050_restore.html) covers it well.

## Where to go from here

There are plenty of ways to extend this. You could create a cron job or script to automate the backups, set it up on your servers and target important files and databases, or create multiple repositories for better redundancy.

If you have suggestions or want to talk it through, get in touch through the [contact page](https://www.customcodeit.com.au/contact).

## Need a hand with this?

- [Managed IT for Small Business](https://www.customcodeit.com.au/managed-it)

    Managed IT for small business: updates, antivirus, backups, email, networks and remote support, from a husband-and-wife team in Pittsworth, Queensland.

## More from the blog

Kyle Murphy

23 Oct 2024

### [How-To Guide: Back Up Your Google Drive](https://www.customcodeit.com.au/blog/how-to-guide-back-up-your-google-drive)

Storing files on Google Drive isn't a backup. Here are four ways to back up Google Drive, from a manual download to Synology Active Backup.

- guide
- backups
- google drive

Kyle Murphy

17 Sept 2024

### [Spatie Laravel Backup - sh: mysqldump: command not found](https://www.customcodeit.com.au/blog/spatie-laravel-backup-command-not-found-mysql)

A quick fix for the "sh: mysqldump: command not found" error when running Spatie's Laravel-Backup from a web interface, by setting the dump binary path.

- tutorial
- troubleshooting
- quick tip
- laravel
- spatie

Kyle Murphy

15 Sept 2024

### [Password Managers: Securing Your Digital Life (Part 1)](https://www.customcodeit.com.au/blog/securing-your-digital-life-tips-best-practices-part-1-password-managers)

What a password manager is, why you need one, how to choose a master password and what a business gains from using one. Part 1 of 3.

- password managers
- tutorial
- information

## You made it this far, you should probably contact us.

Take a moment to celebrate, give that scrolling finger a break, then contact us because we'd love to hear from you.

[Shop 07 4646 2400](tel:0746462400) [Mobile 0466 624 345](tel:0466624345)

---

Page: https://www.customcodeit.com.au/blog/linux-backups-with-restic-and-s3
About this site, for agents: https://www.customcodeit.com.au/llms.txt
