ReinerNippes / nextcloud_on_docker

Run Nextcloud in Docker Container on various Linux Hosts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to restore a backup from restic

blumberg opened this issue · comments

First of all. Congrats on this amazing installer.

One thing that I would like to know is how I restore a backup from restic if I need to rebuild my OS (or move to a different server)?

It would be great to have this instruction on README.

Cheers,

Hi @blumberg
Restic is a great tool and makes it nice and easy to restore backups.

Currently, the backup script located here backs up your nextcloud directory which you configure in the playbooks inventory file.
Restic's documentation here will provide useful for restoring your backup.

To restore the latest backup you could use the following command:

restic -r /path/to/restic/repository restore latest --target /path/to/directory/to/restore/backup/to
  • /path/to/restic/repository being the inventory file variable {{ restic_repo }} which you configure.
  • /path/to/directory/to/restore/backup/to being the directory you want to restore your backup to.

Hope this helps 👍

Sorry for the ate answer.

Here is an article about restic itself: https://www.ostechnix.com/restic-fast-secure-efficient-backup-application/

To restore single file I would use the restic mount option. It gives you access to any file and version in the restic repo. You can browse through all files and copy the one needed. after copying you have to run docker exec -u www-data nextcloud php occ files:scan --all.

A "bare metal" restore would be:

  • install the OS
  • run the playbook
  • stop nginx, php-fpm, redis and database server container
  • delete /opt/nextcloud/*
  • restore all directories and files from restic repo to /opt/nextcloud
  • start the database container
  • drop the nextcloud database created during playbook run
  • restore the database dump in /opt/nextcloud/databasedump
  • if the server named changed you have to edit config/config.php
  • start redis, php-fpm, nginx container.

It might also work to disable the nextcloud_config role in line 12 of the playbook.

- { role: nextcloud_config, when: (state is undefined or 'absent' not in state) }

But didn't test it yet.

I would recommend to test this. If you use cloud storage (e.g. S3 compatible) or a NFS share as a restic repo it super easy just to install a new instance and exercise a restore. If you use a local directory (bad idea anyway) you have to copy this to the new machine before.