RecoveringDeletedData - PresConsUIUC/PSAP GitHub Wiki
When content is deleted from the database, the only way to restore it is from a nightly database backup. But whole backups can't be restored, because that would wipe out all changes made by other users since the backup.
To deal with this situation, the PSAP application has functionality to bulk-export and bulk-import a single institution's data. Backup data is loaded into a one-off application instance, from which the institution data is exported, and and then imported into the production instance. All data associated with an institution is included, except users.
How to do it
-
Start up a new PSAP development environment with application and PostgreSQL database.
-
Locate the backup file. (For psap.library.illinois.edu, see here)
-
Copy the file into the development environment and load it into PostgreSQL, e.g.:
$ createdb psap_backup -T template0
$ psql -f backup.sql psap_backup
-
Edit the PSAP application's
database.yml
to use the recovered database. -
Find the institution's ID. This will appear in URLs as:
/institutions/:id
-
Use that ID to export all of the institution's data:
bundle exec rake psap:export_institution[:id] > recovered.json
-
Copy this file onto the production server.
-
Load it into the application:
bundle exec rake psap:import_institution[/path/to/recovered.json]