install restic as root
sudo -i
wget https://github.com/restic/restic/releases/download/v0.9.4/restic_0.9.4_linux_amd64.bz2
bunzip2 restic_0.9.4_linux_amd64.bz2
mv restic_0.9.4_linux_amd64 /usr/local/bin/restic
chmod 0755 /usr/local/bin/restic
mount the backup directory to /mnt/nc-backup
set two environment variables
export RESTIC_REPOSITORY="/var/nc-backup"
export RESTIC_PASSWORD="oJSesetLzRgphy9UwmWxi50oE0dkYa16"
initialize restic
restic init
create a backup script /usr/local/bin/backup_nextcloud.sh
#!/bin/bash
export RESTIC_REPOSITORY="/mnt/nc-backup"
export RESTIC_PASSWORD="oJSesetLzRgphy9UwmWxi50oE0dkYa16"
# abort entire script if any command fails
set -e
# Make sure nextcloud is enabled when we are done
trap "sudo -u www-data php /var/www/nextcloud/occ maintenance:mode --off" EXIT
# set nextcloud to maintenance mode
sudo -u www-data php /var/www/nextcloud/occ maintenance:mode --on
# unlock restic
/usr/local/bin/restic unlock
# backup the database
sudo -u postgres pg_dump -c -U postgres nextcloud_db | /usr/local/bin/restic backup --stdin --stdin-filename db_postgres_nextcloud.sql
# backup the data dir
/usr/local/bin/restic backup /mnt/nc-data /var/www/nextcloud
# turn maintenance mode off
sudo -u www-data php /var/www/nextcloud/occ maintenance:mode --off
# delete trap
trap "" EXIT
# clean up backup dir
/usr/local/bin/restic forget --keep-daily 7 --keep-weekly 5 --keep-monthly 12 --keep-yearly 75
/usr/local/bin/restic prune
you may want to add other files and directories to the line
# backup the data dir
/usr/local/bin/restic backup /mnt/nc-data /var/www/nextcloud
e.g. the apache2 config
for more infos about restic look here: https://restic.readthedocs.io/en/latest
restore (single file): you “mount” the backups to /mnt/restore with
mkdir /mnt/restore
export RESTIC_REPOSITORY="/var/nc-backup"
export RESTIC_PASSWORD="oJSesetLzRgphy9UwmWxi50oE0dkYa16"
/usr/local/bin/restic mount /mnt/restore
now you can navigate through the backups and look for the file you want to restore and copy it back to /mnt/nc-data/<username>/files
/mnt
├── hosts
│ └── ip-172-31-68-249
│ ├── 2019-04-14T07:29:31Z
│ │ └── db_postgres_nextcloud.sql
│ ├── 2019-04-14T07:29:32Z
│ │ └── var
│ │ └── nc-data
│ ├── 2019-04-14T07:29:33Z
│ │ └── var
│ │ └── www
│ └── latest -> 2019-04-14T07:29:33Z
├── ids
│ ├── 0d0ba44a
│ │ └── var
│ │ └── nc-data
│ │ ├── admin
│ │ ├── appdata_ocjb4w2lzfyj
│ │ ├── audit.log
│ │ ├── files_external
│ │ ├── index.html
│ │ └── nextcloud.log
│ ├── 401c5e8e
│ │ └── var
│ │ └── www
│ │ └── nextcloud
│ └── 827fbdde
│ └── db_postgres_nextcloud.sql
├── snapshots
│ ├── 2019-04-14T07:29:31Z
│ │ └── db_postgres_nextcloud.sql
│ ├── 2019-04-14T07:29:32Z
│ │ └── var
│ │ └── nc-data
│ │ ├── admin
│ │ ├── appdata_ocjb4w2lzfyj
│ │ ├── audit.log
│ │ ├── files_external
│ │ ├── index.html
│ │ └── nextcloud.log
│ ├── 2019-04-14T07:29:33Z
│ │ └── var
│ │ └── www
│ │ └── nextcloud
│ └── latest -> 2019-04-14T07:29:33Z
└── tags
don’t forget to run
sudo -u www-data php /var/www/nextcloud/occ file:scan --all
full restore:
install nextcloud and restic
stop postgres, redis, php, apache2
delete /mnt/nc-data and /var/www/nextcloud
find the snapshot id of the latest backup restic snapshots
restore the directories restic restore <snapshot-id>
or restic restore latest --target /
restore the database psql nextcloud_db < db_postgres_nextcloud.sql
restart everything or reboot
more or less like this. you should try and exercise this on a new maschine a couple of times. 
this has nothing to do with nextcloud. to find a good backup and recovery strategy is a general task in IT.
p.s.: I wouldn’t backup to a mounted file system. because it wouldn’t cover sudo rm -rf / you should look if can use sftp or the restic REST server to connect to your freenas.
further reading: http://plone.4aero.com/Members/lmarzke/talks/restic/
and to setup a test env for restore: → GitHub - ReinerNippes/nextcloud: Ansible playbook to install nextcloud, php, nginx or apache, mariadb or postgres, redis-server, onlyoffice or collabora office