Backing up and restoring supporting services

Fedora

See https://wiki.lyrasis.org/display/FEDORA475/RESTful+HTTP+API+-+Backup+and+Restore

Create the backup:
curl -X POST "http://fedora:8080/fedora/rest/fcr:backup"
This will return the path of the backup in the response body.

In docker environment you can copy a backup out of the container (to a directory of your choice, here /tmp/backups/fcrepo) using:
docker cp avalon_fedora_1:<snapshot_path> /tmp/backups/fcrepo/<snapshot_dir>
You can copy a backup back into the container for restoring using:
docker cp /tmp/backups/fcrepo/<snapshot_dir> avalon_fedora_1:<snapshot_path>

Restore a backup:
curl -X POST --data-binary "<snapshot_path>" "http://fedora:8080/fedora/rest/fcr:restore"

(There also is a separate import/export tool which can possibly be used to backup/restore. See https://github.com/fcrepo-exts/fcrepo-import-export/tree/fcrepo-import-export-0.3.0#running-the-importexport-utility-with-command-line-arguments)

Solr

See https://solr.apache.org/guide/solr/latest/deployment-guide/backup-restore.html#user-managed-clusters-and-single-node-installations

First make sure all data has been committed:
bundle exec rails r "puts ActiveFedora::SolrService.commit"

Start backup:
curl "${SOLR_URL}/replication?command=backup"
Check on its progress:
curl "${SOLR_URL}/replication?command=details&wt=xml"
Snapshot will be stored in /var/solr/data/avalon/data/snapshot.<timestamp>

In docker environment you can copy snapshot out of the container (to a directory of your choice, here /tmp/backups/solr) using:
docker cp avalon_solr_1:/var/solr/data/avalon/data/snapshot.<timestamp> /tmp/backups/solr/snapshot.<timestamp>
You can copy a snapshot back into the container for restoring using:
docker cp /tmp/backups/solr/snapshot.<timestamp> avalon_solr_1:/var/solr/data/avalon/data/snapshot.<timestamp>

Restore latest snapshot: (looks in data directory for snapshot.<timestamp> directories and chooses the most recent)
curl "${SOLR_URL}/replication?command=restore"
Check on its progress:
curl "${SOLR_URL}/replication?command=restorestatus&wt=xml"

If you need to restore a specific snapshot you can use the timestamp as the snapshot name:
curl "${SOLR_URL}/replication?command=restore&name=<timestamp>"

Redis

See https://developer.redis.com/explore/import/#restore-an-rdb-file

Find the location of dump.rdb (at /data/dump.rdb in docker environment) and copy to backup location.

To restore:
1. Stop redis
2. Copy backup dump.rdb to its original location
3. Restart redis

There is a small chance that the RDB is incomplete so it is possible to setup redis to also use an append only file which combined with the RDB is safest. This can be configured by passing some to the redis command:
redis-server --appendonly yes --maxmemory-policy noeviction --auto-aof-rewrite-percentage 100 --auto-aof-rewrite-min-size 8mb
See https://redis.io/docs/management/persistence/ for more details.

Minio (if using)

Backing up and restoring minio can be as simple as copying the bucket directories to a backup location and restoring them. (This approach will restore binary content but may lose object version history and metadata.)

In docker environment you should mount external storage so buckets persist across container restarts, but if you don’t have that setup (like in the development environment) you can copy the buckets out of the container using:

docker cp avalon_minio_1:/data/derivatives /tmp/backups/minio/derivatives docker cp avalon_minio_1:/data/fcrepo /tmp/backups/minio/fcrepo docker cp avalon_minio_1:/data/masterfiles /tmp/backups/minio/masterfiles docker cp avalon_minio_1:/data/preserves /tmp/backups/minio/preserves docker cp avalon_minio_1:/data/supplementalfiles /tmp/backups/minio/supplementalfiles

You can restore the backups into the container using:

docker cp /tmp/backups/minio/derivatives avalon_minio_1:/data/derivatives docker cp /tmp/backups/minio/fcrepo avalon_minio_1:/data/fcrepo docker cp /tmp/backups/minio/masterfiles avalon_minio_1:/data/masterfiles docker cp /tmp/backups/minio/preserves avalon_minio_1:/data/preserves docker cp /tmp/backups/minio/supplementalfiles avalon_minio_1:/data/supplementalfiles