# Daily Automated Backups using Restic

**URL:** <https://forum.yunohost.org/t/daily-automated-backups-using-restic/16812>\
**Category:** Tutorials\
**Tags:** english\
**Created:** [August 11, 2021, 3:13am UTC](https://forum.yunohost.org/t/daily-automated-backups-using-restic/16812 "2021-08-11T03:13:30Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![arkadi](https://forum.yunohost.org/user_avatar/forum.yunohost.org/arkadi/32/5350_2.png) [@arkadi](https://forum.yunohost.org/u/arkadi)\
**Post date:** [August 11, 2021, 3:13am UTC](https://forum.yunohost.org/t/daily-automated-backups-using-restic/16812/1 "2021-08-11T03:13:30Z")

</div>

_Restic_ is a newer backup solution, but far easier to setup than Borg imho. This tutorial is to show you how easy it is to setup, and run daily on Yunohost.

I love Yunohost and wish to give a little back to this community with this walk-through that I hope will help some people.

_ **What is restic?** _

> **[GitHub - restic/restic: Fast, secure, efficient backup program](https://github.com/restic/restic/)**
>
> Fast, secure, efficient backup program. Contribute to restic/restic development by creating an account on GitHub.

[https://restic.readthedocs.io/en/stable/](https://restic.readthedocs.io/en/stable/)

**1. Setup Your Backup Location**

Prepare a your backup location (another computer on the LAN, or a USB hard drive, or an internal hard drive)

NOTE: This sort of backup doesn’t protect you against theft, fire, or flood. You should have an offsite backup as well as this local one.

In this example, I am using an internal hard drive that is mounted at: `/mnt/backup`

**2. Install Restic**

`sudo apt-get install restic`

You can also [download the latest binary from the Github page](https://github.com/restic/restic/releases/latest), or even compile your own binary with Go.

After installing, check that it works with the command:  
`restic version`

It will return something like this:  
`restic 0.12.1 compiled with go1.16.6 on linux/amd64`

**3. Setup the Repository**  
A repository (repo) can hold different backups (snapshots) from different users, or even different machines. They can all be backed up in the same repository as long as the user has the right password. In this example I’ve called the repository my-backups.

`$ restic init --repo /mnt/backup/my-backups enter password for new repository: enter password again: created restic repository 085b3c76b9 at /mnt/backup/my-backups Please note that knowledge of your password is required to access the repository. Losing your password means that your data is irrecoverably lost.`

NOTE: Make sure you save this password in a password manager. If you lose it, you lose access to all your backups.

[More info about setting up repositories](https://restic.readthedocs.io/en/stable/030_preparing_a_new_repo.html), if you want to make an offsite backup - look into using a REST-server.

**4. Make a Backup**  
Now you will make a test backup of Yunohost Backups folder. You make regular backups using `sudo yunohost backup` right?

`sudo restic backup /home/yunohost.backup/archives --verbose --tag yunohost`

That’s it! If you run this command again, it will make another snapshot of those files, but it deduplicates the backup so only the files that have changed will be added to the repo.

**5. Check your Backup**  
Make sure it all works!

```auto
$ sudo restic -r /mnt/backup/my-backups snapshots
enter password for repository: 
repository 9f935439 opened successfully, password is correct
ID Time Host Tags Paths
----------------------------------------------------------------------------------------------------
c72d2899 2021-07-09 01:00:02 blah.com yunohost /home/yunohost.backup/archives
----------------------------------------------------------------------------------------------------
1 snapshot

```

**6. Automate Your Backups**  
Since restic deduplicates backups it makes sense to make daily backups of your important data. If you automate your backups, you won’t forget to do it and you’ll have a backup when you really need it!

**6.1 Setup Password File**  
Your server needs a password to your repo so it can automate your backups.

```auto
cd ~
nano .restic-backup
export RESTIC_REPOSITORY="/mnt/backup/my-backups"
export RESTIC_PASSWORD="YOURPASSWORDHERE"

```

**6.2 Setup Script**  
It’s better to have a shell script holding all your backup tasks so they can run one after another because it’s hard to judge how long a backup will take.

```auto
nano restic-backups

```

Then paste the following:

```auto
#!/bin/bash
source /home/admin/.restic-backup
restic backup /home/yunohost.backup/archives --tag yunohost
restic backup /home/admin/ --tag home
# any other backups you want

```

**6.3 Setup a Cron Job**

`0 11 * * * root /home/admin/restic-backups`

There you go, now you have a simple solution to make daily backups!  
If you want to go further:

- make a script to do ‘prune’ jobs (deleting old backups - i.e. snapshots)
- get another computer, and setup an offsite backup using a [REST-server](https://github.com/restic/rest-server) (I am doing this and will make another tutorial in the future for it)

Thanks for reading! Any suggestions on how to improve this, please let me know. Any questions about running restic and Yunohost - ask away.

Put this on my blog for posterity.

> **[Daily Automated Backups with Restic](https://blog.arkadi.one/p/daily-automated-backups-with-restic/)**
>
> Restic is a newer backup solution, but far easier to setup than Borg backup, in my humble opinion. This tutorial is to show you how easy it is to setup, and run daily on Yunohost. This tutorial could also be used to setup Restic on Debian or other...

---

<div class="post-metadata">

**Author:** ![Lapineige](https://forum.yunohost.org/letter_avatar_proxy/v4/letter/l/bc79bd/32.png) [@Lapineige](https://forum.yunohost.org/u/Lapineige)\
**Post date:** [August 11, 2021, 7:23am UTC](https://forum.yunohost.org/t/daily-automated-backups-using-restic/16812/2 "2021-08-11T07:23:47Z")

</div>

Thanks for the tutorial 🙂

One might wonder which tool is “the best one”. As far I know, both are more adapted to some use case. Here is some information about it:

- Restic seems faster to operate (it’s multi-threaded), it supports more backends (not only ssh), and is able to run cross-servers deduplications (I guess that’s not important here as most of us don’t have dozens of servers ^^).
- Borg is more space efficient (thanks to compression, Restic doesn’t have it yet [Implement Compression · Issue #21 · restic/restic · GitHub](https://github.com/restic/restic/issues/21)), and older so the ecosystem around it is probably richer.
- For the record, here is a (relatively recent) blog article comparing Borg and Restic pros/cons: [https://it-notes.dragas.net/2020/06/30/searching-for-a-perfect-backup-solution-borg-and-restic/](https://it-notes.dragas.net/2020/06/30/searching-for-a-perfect-backup-solution-borg-and-restic/)

---

<div class="post-metadata">

**Author:** ![arkadi](https://forum.yunohost.org/user_avatar/forum.yunohost.org/arkadi/32/5350_2.png) [@arkadi](https://forum.yunohost.org/u/arkadi)\
**Post date:** [August 11, 2021, 7:33am UTC](https://forum.yunohost.org/t/daily-automated-backups-using-restic/16812/3 "2021-08-11T07:33:59Z")

</div>

> [@Lapineige](#):
>
> hreaded), it supports more backends (not only ssh), and is able to run cross-servers

Like you said, it depends what tool is best for somebody and their use case but I think restic ticks lots of boxes:

- space is so ‘cheap’, that compression doesn’t matter to most
- the setup is so fast with restic, it’s better to have a backup, any backup, rather than no backup

I know I used borg for a few years but the setup was so onerous for me. I really disliked the user experience of it.

---

<div class="post-metadata">

**Author:** ![someonesusername](https://forum.yunohost.org/user_avatar/forum.yunohost.org/someonesusername/32/5789_2.png) [@someonesusername](https://forum.yunohost.org/u/someonesusername)\
**Post date:** [September 13, 2021, 12:04am UTC](https://forum.yunohost.org/t/daily-automated-backups-using-restic/16812/4 "2021-09-13T00:04:25Z")

</div>

> [@arkadi](#):
>
> **6.2 Setup Script**  
> It’s better to have a shell script holding all your backup tasks so they can run one after another. It’s hard to
> 
> `nano restic-backups #!/bin/bash source /home/admin/.restic-backup restic backup /home/yunohost.backup/archives --tag yunohost restic backup /home/admin/ --tag home etc.`

I don’t get this part, copying and pasting this command opens a blank nano…

> [@arkadi](#):
>
> sudo restic backup /home/yunohost.backup/archives --verbose --tag yunohost

ohhhhh now i see 😃

---

<div class="post-metadata">

**Author:** ![arkadi](https://forum.yunohost.org/user_avatar/forum.yunohost.org/arkadi/32/5350_2.png) [@arkadi](https://forum.yunohost.org/u/arkadi)\
**Post date:** [September 13, 2021, 1:12am UTC](https://forum.yunohost.org/t/daily-automated-backups-using-restic/16812/6 "2021-09-13T01:12:59Z")

</div>

Thanks, I edited that block of code for more clarity.

---

<div class="post-metadata">

**Author:** ![ljf](https://forum.yunohost.org/user_avatar/forum.yunohost.org/ljf/32/58_2.png) [@ljf](https://forum.yunohost.org/u/ljf)\
**Post date:** [September 13, 2021, 1:16am UTC](https://forum.yunohost.org/t/daily-automated-backups-using-restic/16812/7 "2021-09-13T01:16:20Z")

</div>

Just a question: do you know about restic app for yunohost ?

> **[GitHub - YunoHost-Apps/restic\_ynh: Restic package for YunoHost](https://github.com/YunoHost-Apps/restic_ynh)**
>
> Restic package for YunoHost. Contribute to YunoHost-Apps/restic\_ynh development by creating an account on GitHub.

We need a better doc for this app on : [Restic | Yunohost Documentation](https://yunohost.org/en/backup/restic)

---

<div class="post-metadata">

**Author:** ![arkadi](https://forum.yunohost.org/user_avatar/forum.yunohost.org/arkadi/32/5350_2.png) [@arkadi](https://forum.yunohost.org/u/arkadi)\
**Post date:** [September 13, 2021, 1:22am UTC](https://forum.yunohost.org/t/daily-automated-backups-using-restic/16812/8 "2021-09-13T01:22:19Z")

</div>

Thanks. I know of it, but I don’t need it. Also sftp is very slow compared to rest-server.

I am making offside restic backups using another computer running Debian 10. I’ve also installed wireguard, and [rest-server](https://github.com/restic/rest-server) on it. I have my yunohost backup to it every night over the wireguard connection using HTTP. I was going to make a quick tutorial on it at some later time.

> ## Why use Rest Server?
> 
> Compared to the SFTP backend, the REST backend has better performance, especially so if you can skip additional crypto overhead by using plain HTTP transport (restic already properly encrypts all data it sends, so using HTTPS is mostly about authentication).
> 
> _(from rest-server github page)_

---

<div class="post-metadata">

**Author:** ![someonesusername](https://forum.yunohost.org/user_avatar/forum.yunohost.org/someonesusername/32/5789_2.png) [@someonesusername](https://forum.yunohost.org/u/someonesusername)\
**Post date:** [September 13, 2021, 10:04am UTC](https://forum.yunohost.org/t/daily-automated-backups-using-restic/16812/9 "2021-09-13T10:04:19Z")

</div>

So you are telling that I did a manual setup while it was already there?!

---

<div class="post-metadata">

**Author:** ![Irene.lewis94](https://forum.yunohost.org/letter_avatar_proxy/v4/letter/i/e68b1a/32.png) [@Irene.lewis94](https://forum.yunohost.org/u/Irene.lewis94)\
**Post date:** [September 16, 2021, 5:30pm UTC](https://forum.yunohost.org/t/daily-automated-backups-using-restic/16812/10 "2021-09-16T17:30:32Z")

</div>

Thanks for the share!

---

<div class="post-metadata">

**Author:** ![someonesusername](https://forum.yunohost.org/user_avatar/forum.yunohost.org/someonesusername/32/5789_2.png) [@someonesusername](https://forum.yunohost.org/u/someonesusername)\
**Post date:** [September 17, 2021, 4:07pm UTC](https://forum.yunohost.org/t/daily-automated-backups-using-restic/16812/11 "2021-09-17T16:07:29Z")

</div>

> [@arkadi](#):
>
> `nano restic-backups`

I’m still dazed and confused but trying to continue, however on which path should we create the file?

---

<div class="post-metadata">

**Author:** ![arkadi](https://forum.yunohost.org/user_avatar/forum.yunohost.org/arkadi/32/5350_2.png) [@arkadi](https://forum.yunohost.org/u/arkadi)\
**Post date:** [September 18, 2021, 11:56pm UTC](https://forum.yunohost.org/t/daily-automated-backups-using-restic/16812/12 "2021-09-18T23:56:30Z")

</div>

> [@arkadi](#):
>
> `cd ~`

You can create it anywhere, as long as you remember where it is and call it later from that path in cron (step 6.3)

I created it in ~ (/home/admin directory). I actually made a ~/bin directory where I keep my scripts.

---

<div class="post-metadata">

**Author:** ![someonesusername](https://forum.yunohost.org/user_avatar/forum.yunohost.org/someonesusername/32/5789_2.png) [@someonesusername](https://forum.yunohost.org/u/someonesusername)\
**Post date:** [September 19, 2021, 1:38pm UTC](https://forum.yunohost.org/t/daily-automated-backups-using-restic/16812/13 "2021-09-19T13:38:53Z")

</div>

Yeah, I have undone the manual install and did the app version 😉 .

---

<div class="post-metadata">

**Author:** ![Irene.lewis94](https://forum.yunohost.org/letter_avatar_proxy/v4/letter/i/e68b1a/32.png) [@Irene.lewis94](https://forum.yunohost.org/u/Irene.lewis94)\
**Post date:** [September 22, 2021, 6:19pm UTC](https://forum.yunohost.org/t/daily-automated-backups-using-restic/16812/14 "2021-09-22T18:19:52Z")

</div>

Great thread! Thanks for the share!

---

<div class="post-metadata">

**Author:** ![arkadi](https://forum.yunohost.org/user_avatar/forum.yunohost.org/arkadi/32/5350_2.png) [@arkadi](https://forum.yunohost.org/u/arkadi)\
**Post date:** [February 20, 2022, 9:50am UTC](https://forum.yunohost.org/t/daily-automated-backups-using-restic/16812/15 "2022-02-20T09:50:35Z")

</div>

People reading this thread might be interested in my latest tutorial:

> **[Making Offsite Yunohost Backups using Rest-Server, Restic & Wireguard](https://blog.arkadi.one/p/making-offsite-yunohost-backups-using-rest-server-restic-wireguard/)**
>
> Making Offsite Yunohost Backups using Rest-Server, Restic & Wireguard If you only have local backups, you might be unprotected if the backups are physically compromised by fire, flood, or earthquake. It is prudent to have offsite backups.
> Aim To...

If you have an extra server somewhere, or are on good terms with a friend running a server 😃

---

<div class="post-metadata">

**Author:** ![Bauerbyter](https://forum.yunohost.org/user_avatar/forum.yunohost.org/bauerbyter/32/7404_2.png) [@Bauerbyter](https://forum.yunohost.org/u/Bauerbyter)\
**Post date:** [December 22, 2022, 12:08pm UTC](https://forum.yunohost.org/t/daily-automated-backups-using-restic/16812/16 "2022-12-22T12:08:10Z")

</div>

@arkadi Thanks for this Tutorial, installation was pretty easy with that. But one question about WHAT to backup.  
Should we backup the “yunohost backup” snapshots or everything in “/var/www”  
I dont have enough diskspace ony my yunohost server for mulitple yunohost backups, so I would create one every day, send it via restic to the repo (another server), prune everything older than 7 days and delete the local yunohost backup. But with that every day I have a complete snapshot of my system, not only the changes, right?  
If I would backup /var/www I would have only the changes.  
Am i wrong?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![lydra](https://forum.yunohost.org/letter_avatar_proxy/v4/letter/l/94ad74/32.png) [@lydra](https://forum.yunohost.org/u/lydra)\
**Post date:** [December 22, 2022, 12:27pm UTC](https://forum.yunohost.org/t/daily-automated-backups-using-restic/16812/17 "2022-12-22T12:27:26Z")

</div>

Hello,  
Here is our little experience managing YunoHost instances for several customers now.  
We have developed an Ansible collection to easily automate backup configuration for YunoHost ([available here if you need](https://lab.frogg.it/lydra/yunohost/clients-offre-ynh)).  
Anyway, for each instance we have three daily backups:

- One backup of YunoHost using a script that basically does `yunohost backup`. The archive is locally stored and the script removes all backups before the 3 last days so it’s not too much data.
- One backup of the local archive on a remote Borg Backup server.
- One backup of the local archive on a remote Restic bucket. In this case, some cloud providers give some free Go of S3 buckets. You can play with the retention policy of your Restic configuration to have “free backup storage”. 😉

---

<div class="post-metadata">

**Author:** ![arkadi](https://forum.yunohost.org/user_avatar/forum.yunohost.org/arkadi/32/5350_2.png) [@arkadi](https://forum.yunohost.org/u/arkadi)\
**Post date:** [December 22, 2022, 12:31pm UTC](https://forum.yunohost.org/t/daily-automated-backups-using-restic/16812/18 "2022-12-22T12:31:42Z")

</div>

What to backup is up to you.

For myself, if I encounter a major system error, I will just reinstall. My data and bash scripts are the most important things for me. I don’t even use the `yunohost backup` stuff because I don’t really understand what it is doing or backing up.

---

<div class="post-metadata">

**Author:** ![drh](https://forum.yunohost.org/user_avatar/forum.yunohost.org/drh/32/7295_2.png) [@drh](https://forum.yunohost.org/u/drh)\
**Post date:** [January 3, 2023, 6:26am UTC](https://forum.yunohost.org/t/daily-automated-backups-using-restic/16812/19 "2023-01-03T06:26:52Z")

</div>

For those wanting to use restic with Backblaze B2 storage I had luck with this tutorial.

> **[How I Use Restic to Back up My Home Folders to Backblaze B2](https://www.seanh.cc/2022/04/03/restic/)**
>
> My guide to using the open source backup program restic to back up your home folders to Backblaze B2 cloud storage.

---

<div class="post-metadata">

**Author:** ![Luncheon3462](https://forum.yunohost.org/user_avatar/forum.yunohost.org/luncheon3462/32/8582_2.png) [@Luncheon3462](https://forum.yunohost.org/u/Luncheon3462)\
**Post date:** [October 7, 2023, 5:08pm UTC](https://forum.yunohost.org/t/daily-automated-backups-using-restic/16812/20 "2023-10-07T17:08:51Z")

</div>

I also don’t know what to backup and would be grateful if someone could explain what is in Yunohost.backup and what is not in that folder? My biggest concern is nextcloud and Wordpress and all the photos, videos and documents used in each.

Thank you

---

<div class="post-metadata">

**Author:** ![arkadi](https://forum.yunohost.org/user_avatar/forum.yunohost.org/arkadi/32/5350_2.png) [@arkadi](https://forum.yunohost.org/u/arkadi)\
**Post date:** [November 17, 2025, 6:58am UTC](https://forum.yunohost.org/t/daily-automated-backups-using-restic/16812/21 "2025-11-17T06:58:24Z")

</div>

Just necro-bumping this thread to say that Backrest is such high quality now that I have now switched to using it. It is so much easier to deal with Backrest than fiddling with cron jobs.

Also, though it is not documented…you can backup to servers using rest-server (rest:http//server:8000)

More information:

- [Backrest: a cross platform backup orchestrator and WebUI for restic - Community - restic forum](https://forum.restic.net/t/backrest-a-cross-platform-backup-orchestrator-and-webui-for-restic/7069)
- [GitHub - garethgeorge/backrest: Backrest is a web UI and orchestrator for restic backup.](https://github.com/garethgeorge/backrest)

[Next page](https://forum.yunohost.org/t/daily-automated-backups-using-restic/16812.md?page=2)
