ReinerNippes / nextcloud_on_docker

Run Nextcloud in Docker Container on various Linux Hosts
MIT License
203 stars 48 forks source link

How to restore a backup from restic #46

Closed blumberg closed 4 years ago

blumberg commented 4 years ago

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,

ghost commented 4 years ago

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

Hope this helps 👍

ReinerNippes commented 4 years ago

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:

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

https://github.com/ReinerNippes/nextcloud_on_docker/blob/e61b42653f832c522203ff46102fcdbb32be131e/nextdocker.yml#L12

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.