A repository is one among the most prized possessions of a digital library, and it virtually hosts crucially essential data, which no one can afford to lose. Hence we see every system administrator or developer recommending people to take the backup of the filesystem and the database, Which is 101% true, and worth spending time. Backup not only safeguards in an event of disaster, theft, and hardware failure. But it also makes way for library professionals to migrate the repository from one physical computer to the other (*though it has some glitches).
So here is how you take the backup of your DSpace server. I assume you use the Linux installation, but the procedure is moreover the same for windows too. The basic idea is to:
- Take a backup of the PostgreSQL database.
- Copy the Dspace Filesystem (uploads/Asset Store Directory mainly)
- Copy the Apache Webapps Directory (in case of JSPUI/XMLUI customizations)
Database backup can be made using the command-line interface on both Windows and Linux, so Open a Terminal/Command and apply following commands,
pg_dump -U DSpace -h localhost -Fc DSpace > dspacebackup.sql
in the case of Linux execute this command with SU privileges after entering the password of Linux user for DSpace. This will make ‘dspacebackup.sql’ file on Linux home directory
for windows GUI
On a Windows system, there would be an application named ‘PGadmin’ III or 4 depending upon your version. This comes bundled with PostgreSQL installer after you open that utility it will start the PostgreSQL database management system in Graphical Mode as shown below.
in your existing installation of Dspace, this database window will have a database created named ‘DSpace’, it can be anything else, but it is this in most cases. So from here you just need to right-click on the database you want to backup and the context menu will show many options as follows:
We chose, back up here, and it will pop up with another window:
give the details in appropriate fields, like the location and name of the backup file, Encoding, and Role name of the owner of the DSpace database. Click backup and it will make a backup copy on your specified location.
I decided to make a folder named Backup on the Desktop so that everything can be put here, but best practice is to take the backup to some other location, maybe another physical drive.
Just like the following:
Now, with this, half of our work is done, let us move to the filesystem backup.
File System Backup:
In C:/Dspace folder, there would be a folder named assetstore, which holds all your uploaded files and maintains the community and collection structure. An expert user will copy only this folder and a few others if required. But since we want to keep everything safe and under minimal risk, it is better to take a copy backup of the entire DSpace directory. It will be large and time-consuming, but trust me, it is definitely worth it.
With the entire DSpace folder, you will also keep a copy of the logs, and lots of other informative files, which can rescue you if the restore doesn’t go as planned.
In Linux, this can be done with the following command.
zip -r assetstorebacup.zip /DSpace/assetstore
Web apps Backup:
There is a probability that you have made some customizations in your DSpace JSPUI/XMLUI interface, like putting up your institutional logo, Name, color scheme and a lot of other things. And you don’t want to go through the same exercise again if you happen to restore the backup. So it is wise to take a filesystem copy backup of the web apps directory of Tomcat as well, This is where your Dspace JSPUI and XMLUI files reside, and these are in Apache Tomcat installation directory as shown in following image:
So just simply copy the entire web apps directory and paste it in your backup location.
The copy-paste may take some time as per your collection size, but once it finishes, we are done with the backup.
Restore procedure is nothing but reversing the whole process. but keep in mind that it only works well if the DSpace code version of both (source & destination) is the same. because with each successive version of Dspace there are minute changes in the database table structure.
First, you need to copy and paste the filesystem :
Simply copy the folders from the backup location and paste them back to where you copied from.
Database restore is not that difficult too, you need to first create the DSpace role (this is the same as DSpace installation procedure).
Then create a blank database named ‘DSpace’ with the DSpace role assigned to it.
After the creation of the ‘DSpace’ database, right-click on the newly created database icon, and from the context menu, chose ‘Restore’ as shown below:
upon clicking this, it will open another pop-up window, where it will ask for the location of the SQL backup file, in our example I will restore it from the backup folder.
That’s it, once both of these procedures completed, your new server is ready to rock.
make sure to restart the tomcat and Postgres service once.