How to migrate from existing Ubuntu 16.04 installation to docker?

the backup script would look like this

#!/bin/bash

export RESTIC_REPOSITORY="<restic-repo>"
export RESTIC_PASSWORD="<restic-passwd>"

# abort entire script if any command fails
set -e

# Make sure nextcloud is enabled when we are done
trap "sudo -u www-data nextcloud php occ maintenance:mode --off" EXIT

# set nextcloud to maintenance mode
sudo -u www-data nextcloud php occ maintenance:mode --on

# backup the database
sudo docker exec -t nextcloud-db mysqldump --single-transaction -h localhost -u nextcloud -p{{ nc_db_passwd }} nextcloud > /opt/nextcloud/database_dump/db_postgres_nextcloud.sql

# backup the data dir
/usr/local/bin/restic backup /opt/nextcloud --exclude /opt/nextcloud/database 

# turn maintenance mode off
sudo -u www-data nextcloud php 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

you have to edit the two restic parameter at the beginning and the database password.

and - if you want - you have make a backup of the s3 bucket. either your provider offers something equivalent to aws or it can be done with rclone.

restore a single file: i don’t know. i have no experience with s3 as primary storage.
look here and here

restore everything:
run the playbook.
sudo -u www-data nextcloud php occ maintenance:mode --on

restic restore /opt/nextcloud # look at the restic homepage howto do this
import the database dump

well. you’ll do this when you migrate to docker. so you’ll know if it’s working.