Backups & Transferring Data Between Sites¶
The following instructions describe how to back up and restore an Islandora site. This is also used to transfer data between a development and production site, or to sync a staging site with a production site.
Container names are based on the service names defined in your docker-compose.yml file. For example, the Drupal container is typically named drupal, the MariaDB container is mariadb, etc. The following instructions use these standard service names.
Before attempting the following commands, you should familiarize yourself with running commands inside a container and with docker compose cp
Drupal Configuration¶
The typical use case of this is to export your Drupal configuration files out of your development site's Drupal database and onto the host machine. This process lets you check your configuration into your git repository so you can import it into your production site.
Export¶
To export your config run:
Then commit and push your git repo so the new config files are included.
Import¶
To import your config to a production or staging site you first need to git pull the config files you pushed from your development site, then rebuild and restart your custom Drupal container.
Once this is done, your config files will be included in the container. You can then import them by running
Drupal Database¶
The Drupal database contains all your Drupal settings and content. If you want to move configuration settings from development to production you should use the Drupal Configuration instructions above.
These instructions can also be used to move your content from production to staging or development.
Back Up¶
Backing up the Drupal database involves doing a database dump in the drupal container:
docker compose exec drupal \
bash -lc "drush sql-dump -y \
--skip-tables-list=cache,cache_*,watchdog \
--structure-tables-list=cache,cache_*,watchdog \
--result-file=/tmp/drupal.sql"
and then copying that dump from the container to the host machine:
Restore¶
Restoring from a database dump requires copying the dump file into the drupal container:
Then replacing the database with the dump:
And finally, rebuilding the Drupal cache:
Drupal Public Files¶
Drupal's public files contain any files used on static pages. This is also where your Islandora derivatives are stored, which includes FITS, thumbnails, etc.
These instructions can also be used to move your content from production to staging or development.
Back Up¶
Drupal public files can be compressed to a tgz file in the Drupal container:
Then copied to the host machine:
Restore¶
Drupal files can be restored from a tgz file by copying them into the Drupal container:
Then placed in the correct directory inside the Drupal volume:
docker compose exec drupal tar zxvf /tmp/files.tar.gz -C /var/www/drupal/web/sites/default/files
docker compose exec drupal chown -R nginx:nginx /var/www/drupal/web/sites/default/files
docker compose exec drupal rm /tmp/files.tar.gz
Note
This will overwrite existing files if they have the same filename, but does not remove existing files otherwise. If you want to make sure that the public files directory does not contain anything but the newly imported files, you will want to empty the directory before copying the new files in.
Drupal Private Files¶
These instructions can also be used to move your content from production to staging or development.
Back Up¶
Drupal private files can be compressed to a tgz file in the Drupal container:
Then copied to the host machine:
Restore¶
Drupal files can be restored from a tgz file by copying them into the Drupal container:
Then placed in the correct directory inside the Drupal volume:
docker compose exec drupal tar zxvf /tmp/private-files.tgz -C /var/www/drupal/private
docker compose exec drupal chown -R nginx:nginx /var/www/drupal/private
docker compose exec drupal rm /tmp/private-files.tgz
Note
This will overwrite existing files if they have the same filename, but does not remove existing files otherwise. If you want to make sure that the private files directory does not contain anything but the newly imported files, you will want to empty the directory before copying the new files in.
Fedora¶
Fedora 6 uses a file structure called OCFL to store files and metadata. The Fedora database is built based on this OCFL file structure, so we don't actually back up our fedora database. Instead, we back up the files and let Fedora rebuild the database based on them.
Note
These instructions involve moving the entirety of your Fedora data. For small sites this is fine, but you may find this becomes cumbersome as your site grows. You may wish to bind your oclf-root directory as a volume to eliminate the need to run the docker compose cp commands.
Back Up¶
To back up Fedora we create a .tgz file from the ocfl-root directory in the Fedora container:
Then we copy that file to the host machine:
Restore¶
To restore our fedora database we need to copy the backup into the Fedora container:
Empty the existing ocfl-root directory:
Put our backup files in the ocfl-root directory:
docker compose exec fcrepo tar zxvf /tmp/fcrepo-export.tgz -C /data/home/data/ocfl-root/
docker compose exec fcrepo chown -R tomcat:tomcat /data/home/data/ocfl-root/
docker compose exec fcrepo rm /tmp/fcrepo-export.tgz
Drop the existing Fedora database:
Restart Fedora to reinitialize the database from the ocfl-root directory:
Note
It may take a while for the database to be restored. In the meantime, you may see error messages that say Fedora is not connected.