# Backups and howto

This Yunohost server is backed up onto two separate USB drives, both of which are *on-premise*. Several attempts have been made to perform an *off-premise* backup using both [Borg](https://www.borgbackup.org/) and [Restic](https://restic.net/), but I have found them to be more difficult than it’s worth!

**Drive 1 (Drive label: YNHRECOVERY)**

This backup uses the built-in Yunohost backup and recovery service. A simple cron job is used, detailing the time and what is to be backed up.

**FULL BACK UP**

- **Time**: Midnight every Wednesday and Sunday
- **What**: <span style="text-decoration: underline;">EVERYTHING</span>. This is a full backup. Everything is checked off in the Yunohost back service.

**OTHER**

- **Time:** 4 AM <span style="text-decoration: underline;">EVERY</span> day.
- **What**: User home folders and emails

**Drive 2 (Drive label: DATARECOVERY)**

This drive uses the Restic backup/recovery application, which is a third-party application. Again, a cron job is used to detail the times and what items are to be backed up.

- Time: 3 AM <span style="text-decoration: underline;">EVERY</span> day
- What: The following folders are incrementally backed up:  
    
    - */etc*
    - */home*
    - */var/www*
    - */opt*
    - */var/lib/mysql*
    - */usr/share/yunohost*

The difference between the two backups is that the Restic backup is incremental, and the last three backups are kept. The Yunohost backup is **not** incremental; therefore, some administration must be done to prune the drive as it becomes full.

**HOW TO USE THE RESTIC BACKUP SERVICE (BASICS)**

Restic is a backup service that can be installed from the CLI or through the Yunohost application catalogue. On this server, it has been installed using the CLI.

***Where is the Restic app located?*** Type: ***<span style="color: rgb(53, 152, 219);">which restic </span>***will show you where the app is located on your drive.

***Where is my Restic repository located?*** The Restic repository can be found at *media/datarecovery/restic.* This is a symbolic link from the Restic directory on the main drive. The physical drive is a USB spinner labelled “**datarecovery**”.

***What is the latest installed Restic version?***  
Type:<span style="color: rgb(53, 152, 219);"> </span>***<span style="color: rgb(53, 152, 219);">restic version.</span>*** This will tell you the current version, which right now is *restic <span style="text-decoration: underline;">**0.17.3**</span>*

**Can I update Restic?** Type**: <span style="color: rgb(53, 152, 219);">*restic self-update.* </span>**If there is an update available, it will be downloaded and installed.

**Has the backup happened?** Type:***<span style="color: rgb(53, 152, 219);"> r***estic check*** -r /media/datarecovery/restic</span>***

**How do I change the backup schedule?*****<span style="color: rgb(53, 152, 219);"> </span>***Type:***<span style="color: rgb(53, 152, 219);"> crontab -u root -e </span>***Nano will open, and you can edit the time and contents of your backup.

**Can I see the snapshots?** Type: ***<span style="color: rgb(53, 152, 219);">restic -r /media/datarecovery/restic snapshots</span>***

**Can I see the contents of the snapshots?** Type: <span style="color: rgb(53, 152, 219);">***restic ls (snapshotID here) --repo /media/datarecovery/restic***</span>

**Can I mount the snapshot?** Type: <span style="color: rgb(53, 152, 219);">***restic -r /media/datarecovery/restic mount /mnt/restic***</span>

<span style="color: rgb(224, 62, 45);">**NOTE: For most of the above commands, you will require the restic password that you set up when you created your repository, etc.**</span>

<div class="entity-list book-contents" id="bkmrk--2"></div>