Thursday, December 18, 2025

Solving file upload issues in DSpace on Ubuntu

The Problem: Tomcat’s Security Sandbox

If you install Tomcat 9 or 10 using the default Ubuntu package manager (apt), it comes with strict security settings. Even if your folder permissions look correct on the surface, Ubuntu's systemd configuration prevents Tomcat from writing files to directories it doesn't explicitly "trust."

By default, Tomcat is blocked from writing to the DSpace folder. e.g. /opt/dspace, which is where DSpace needs to store uploaded content.

The Solution: Updating the Service File

I applied this solution to DSpace 7 & 8. To fix this, you need to tell the system that Tomcat has permission to write to your DSpace folder. Follow these steps:
Open the Service File: Find your Tomcat systemd unit file (usually located at /lib/systemd/system/tomcat10.service). Check the version of Tomcat.

sudo mousepad /lib/systemd/system/tomcat10.service

Add the Path: Look for the [Security] section and find the lines starting with ReadWritePaths=. Add your DSpace installation path to this list. For example: ReadWritePaths=/opt/dspace
Check the User: Ensure the User= line in that same file matches the owner of your DSpace folder.

See how it looks after updating,

# Security
User=tomcat
Group=tomcat
PrivateTmp=yes
AmbientCapabilities=CAP_NET_BIND_SERVICE
NoNewPrivileges=true
CacheDirectory=tomcat9
CacheDirectoryMode=750
ProtectSystem=strict
ReadWritePaths=/etc/tomcat9/Catalina/
ReadWritePaths=/var/lib/tomcat9/webapps/
ReadWritePaths=/var/log/tomcat9/
ReadWritePaths=/opt/dspace

Reload and Restart: Save the file, then run these commands to apply the changes:
sudo systemctl daemon-reload
sudo systemctl restart tomcat10
Once these changes are made, the "sandbox" is opened, and your file uploads should work immediately.

Reference

Saturday, February 15, 2025

How to automate the backup of DSpace database and folders

Here is a method to automate the backup of the PostgreSQL database and DSpace folders (e.g. assetstore) using a shell script and scheduling through cronjob.

Find the pg_hba.conf file change the method to 'trust'

The pg_hba. conf file resides within the PostgreSQL data directory and consists of a series of lines, each specifying a connection type, database, user, IP address, authentication method, and other details.
The file is located at Ubuntu 24.04 at /etc/postgresql/16/main/pg_hba.conf. Location may be different in Debian Linux. Check the location manually and open the file.

sudo mousepad /etc/postgresql/16/main/pg_hba.conf

Find the following lines and change the term peer to trust,

local   all             postgres                                peer
local   all             all                                     peer
host    all             all             127.0.0.1/32            peer

The output will look like this,

Save and close the file. Restart the PostgreSQL service.

sudo systemctl restart  postgresql

Make a shell script to take the backup

Create a backup folder on your computer. Apply the following command to create a local backup folder on your home folder. Change the location of the folder in the below command before applying it.

sudo mkdir /home/username/backup

The backup location can be a folder inside your cloud storage service like PCloud or Dropbox.
Open a new file inside the folder /usr/local/bin/ to create a shell script.

sudo mousepad /usr/local/bin/dspace-backup.sh

Copy the following content into the file. Make necessary changes in the file, e.g. location of the backup folder, PostgreSQL database name and user. 

#!/bin/bash
#backup of PostgreSQL database
BACKUP_DIR="/home/username/backup/"
FILE_NAME=$BACKUP_DIR`date +%d-%m-%Y-%I-%M-%S-%p`.sql
pg_dump -U db_user db_name > $FILE_NAME

# backup of assetstore folder
zip -r /home/username/backup/assetstore-$(date +%d-%m-%Y-%H.%M).zip /dspace/assetstore

#Delete older files more than 7 days will delete.
find /home/username/backup/* -mtime +7 -exec rm {} \;

Save and close the file.

Make the shell script executable

sudo chmod a+x /usr/local/bin/dspace-backup.sh

Add the crontab entry

Apply the following command to open crontab

sudo crontab -e

Copy and paste the following entries at the end of the editor.
Copy the below lines to the bottom part of the crontab file.

#DSpace backup
10 20 * * * /usr/local/bin/dspace-backup.sh

Change the timing of the backup. Here, backup takes at 8:10 PM.

If you want a backup every 5 hours, apply the following entry.

# DSpace backup
0 */5 * * * /usr/local/bin/dspace-backup.sh

Reference

Tuesday, October 8, 2024

Install DSpace 8 on Debian 12

Here, we use Debian 12 to install DSpace 8. If you don't like the Vanilla Debian, try PepperMintOS, / MX Linux / Linux Mint Debian edition. Beginners can find YouTube videos on how to install Debian Linux.

Prepare the system for Dspace installation

DSpace consists of both a Java-based backend and an Angular-based front end. Both the backend and front end need to be installed separately. Install the prerequisites for the DSpace software. Dspace builds on the Java platform and requires software packages like Tomcat, Solr, Maven, Ant, etc.

Monday, October 7, 2024

Install DSpace 8 on Ubuntu 24.04 LTS

Here, we use Xubuntu 24.04 LTS to install DSpace 8. Xubuntu 24.04 LTS loaded with Snap, which makes the system slow. In such cases, choose snapless Ubuntu-based Linux operating systems like Linux Lite / Rhino Linux / Asmi Linux.

Prepare the system for Dspace installation.

DSpace consists of both a Java-based backend and an Angular-based front end. Both the backend and front end need to be installed separately. Install the prerequisites for the DSpace software. Dspace builds on the Java platform and requires software packages like Tomcat, Solr, Maven, Ant, etc.

Wednesday, May 8, 2024

Add a new item type in item submission page in DSpace 7

Open the following file in a terminal:

sudo mousepad /dspace/config/input-forms.xml

Find the lines for item types.


Copy an existing code for an item type.

<pair>
       <displayed-value>Animation</displayed-value>
       <stored-value>Animation</stored-value>
</pair>

Add new value and paste between any default item types.

<pair>
       <displayed-value>PhD Theses</displayed-value>
       <stored-value>PhD Theses</stored-value>
</pair> 

Save and close the file.
Restart Tomcat and refresh the page to see the change.

sudo systemctl restart tomcat9.service

Tuesday, January 16, 2024

Change the text at DSpace 7 home page


Frontpage template available at [dspace-angular-frontend]\src\themes\dspace\app\home-page\home-news\home-news.component.html. The location of the dspace-angular-dspace may vary.

Open the template file using a text editor like Nano, e.g.

sudo nano /home/dspace/dspace-angular-dspace-7.6.1/src/themes/dspace/app/home-page/home-news/home-news.component.html 

Rebuild the production environment to take effect the changes.

Enter the location of the dspace-angular-dspace. Find the exact location of the [dspace-angular-frontend] and apply the following command. Here is an example of the command,

cd /home/dspace/dspace-angular-dspace-7.6.1/config

Apply the following command

yarn run build:prod

Refresh the home page of DSpace to see the changes made.

Thursday, February 23, 2023

Automate DSpace backups with Cron Task

Database backup

Open a Terminal and log in as a Postgres user,

sudo su - postgres

Create a directory in the Postgres user’s home to store the backups. Apply the following command,

mkdir -p ~/backups

Enter into the crontab:

crontab -e

Add the following entry into the Cron,

#DSpace Postgres backup

10 20 * * * pg_dump -U postgres dbname > ~/postgres/backups/dbname-$(date +%d-%m-%Y-%H.%M).bak

Change the timing of the backup, here backup take at 8:10 PM

Apply  CTRL + O button to save the cron entry.
Then apply CTRL + X to exit from the cron. 

Type exit to exit from Postgres prompt.

Backup of asset store and log folders


Open a terminal and apply the following command to create a folder in Home to hold asset store and log folders.

sudo mkdir dspacebkup

Open crontab to add the entry to automate the folder backup,
sudo su
crontab -e

Add the following lines,

10 20 * * * zip -r /home/vimal/dspacebkup/assetstore-$(date +%d-%m-%Y-%H.%M).zip /dspace/assetstore
10 20 * * * zip -r /home/vimal/dspacebkup/log-$(date +%d-%m-%Y-%H.%M).zip /dspace/log

Change the path based on your local setup.

Saturday, February 4, 2023

Error 500-Service unavailable: how to solve

Many DSpace users got Error 500. To solve the error, check the following things one by one.

Solr

Apply the following commands to restart Solr.

su dspace
/opt/solr/bin/solr start
exit

Tomcat

Apply the following command restart Tomcat

sudo systemctl restart tomcat9.service

Start the user interface

Apply the following commands,

sudo su
pm2 start /home/dspace/dspace-angular-dspace-7.4/dspace-ui.json

Make available DSpace in a local network / web

DSpace version 7 and 8 default port for the front end is 4000. The port needs to open to make DSpace available in a local network. I applied this method on Ubuntu 24.04 and Debian 12. Here are the processes to make available DSpace version 8 in the network. 

Open the Port 4000

ufw is the default firewall configuration tool. Install ufw by applying the following command,
 
sudo apt install ufw
 
Apply the following command to open port 4000 and 8080.

sudo ufw allow 4000
sudo ufw allow 8080
sudo ufw enable 

Network configuration for DSpace

Find the IP address of the computer where DSpace is installed. Apply the following commands to install net-tools software in Ubuntu and know the network details.
 
sudo apt install net-tools 
ifconfig 

Debian users can apply the following command to know the network details,

nmcli -p device show

Note down the details and add the IP address. 
Open the DSpace configuration file, 

sudo mousepad /dspace/config/local.cfg 

Find the following lines and add the IP address/domain name instead of localhost.

dspace.ui.url = http://localhost:4000 
dspace.server.url = http://localhost:8080/server 


Save and close the file. 
Open the following configuration file (make sure the location of the file in your server) of the DSpace front end, 

sudo mousepad /home/dspace/dspace-angular-dspace-8.0/config/config.prod.yml

Find the following piece of lines, 

ssl: false 
host: localhost 
port: 4000 

Change the hostname. Change localhost to the IP address/domain name.

ssl: false 
host: your-ip-address
port: 4000 


Save and close the file.

Enter into the dspace-angular config folder,

sudo su

cd /home/dspace/dspace-angular-dspace-8.0/config

Apply the following command to build the front end,

yarn run build:prod

Start the application using PM2. Apply the following command to start the service,

sudo su
pm2 start /home/dspace/dspace-angular-dspace-8.0/dspace-ui.json

Restart the Tomcat,

sudo systemctl restart tomcat10.service

Change localhost to the IP address. Save and close the file.
 
Restart PC. Try to load DSpace 7 from other PC in the network. 
Example, http://192.168.1.20:4000

References

Monday, December 12, 2022

Upgrading DSpace 6 to 7

Take a backup of the DSpace 6 database and folders

Open a Terminal and apply the following commands,

sudo su - postgres
pg_dump dspace > dspace.backup


The above command takes a backup of the DSpace database and stores in /var/lib/postgresql. Copy the database.backup file to a safe place.

Saturday, December 3, 2022

Install DSpace 7 on Debian 11 / Ubuntu 22.04 LTS

We use Debian 11 (Bull Eye) Xubuntu 22.04 LTS to install DSpace 7. ISO file of Debian 11 can be downloaded from the link (I prefer Debian with MATE desktop). Xubuntu 22.04 can be downloaded from here. Users who feel challenged to use barebone Debian can also try Dbebian-based Linux operating systems like Pepper Mint OS. Either burn the ISO file to a pen drive or DVD. Install Debian 11 on the machine. Create a user account during the installation (e.g. mgu). Create the user with the name dspace after installing the Linux-based operating system. If you have already run on Ubuntu/Debian (e.g. for Koha), create a dspace user.

Prepare the system for Dspace installation.

DSpace consists of both a Java-based backend and an Angular-based front end. Both the backend and front end need to be installed separately. Install the prerequisites for the Dspace software. Dspace builds on the Java platform and requires software packages like Tomcat, Solr, Maven, Ant, etc.

Thursday, July 28, 2022

Install DSpace 6.3 on Ubuntu 20.04

We use Xubuntu 20.04 LTS for the installation of DSpace 6. ISO file of the operating system can be downloaded from the Xubuntu website, https://xubuntu.org/release/20-04. No problem using other Ubuntu flavors (e.g. Ubuntu with GNOME, KDE, Lubuntu) for the installation. Either burn the ISO file to a pen drive or DVD. Install the Xubuntu on the machine. Create a user account during the installation (e.g. mgu). Create the user with the name dspace after the installation of Linux based operating system. If you have already run on Ubuntu/Debian (e.g. for Koha), create a dspace user.

Prepare the system for Dspace installation.

DSpace builds on the Java platform and it requires a set of software packages like Tomcat, Solr, Maven, Ant, etc. Install the prerequisites for the Dspace software. 

Thursday, May 19, 2022

MediaFilters for full-text search and thumbnail creation

Thumbnails of documents give more visibility for PDF documents of books, reports, articles and magazines. DSpace filter-media script extracts the PDF files for full-text search and thumbnail creation. and after submitting an item. Here is the view of an item without a thumbnail,


Filter-Media script can run either individually after submission of an item for the instant result. Apply the following command to run filter-media,

sudo /dspace/bin/dspace filter-media

The filter-Media command can be added to Crontab to schedule the filter-media command. Add these cron settings under the Linux user account which is running Tomcat (and owns the dspace installation directory).

crontab -e

If the DSpace run on a 24x7 working server machine, add the following entries into the Crontab,

# Run the media filter at 03:00 am every day.
0 3 * * * /dspace/bin/dspace filter-media

If you would like to change the timing, add a convenient time. See the different Cron time examples available here. See the thumbnails along with the item after applying the filter-media script.

References

Media filters for Transforming DSpace Content
https://wiki.lyrasis.org/display/DSDOC7x/Mediafilters+for+Transforming+DSpace+Content


Wednesday, May 18, 2022

OAI-PMH / OAI-ORE Harvester


OAI-PMH and OAI-ORE are the standards for the description and exchange of metadata and digital objects for archives. DSpace is compatible with OAI-PMH and OAI-ORE. It means, it's possible to import metadata and digital objects (e.g. text, images, data, and video) into DSpace. A DSpace administrator can import metadata from an e-journal/e-book/institutional repository (e.g. arxiv.org, doabooks.org, doaj.org). Harvesting metadata and digital objects from an external source will enrich the institutional repository run on DSpace and it also enhance the user experience. Following are the steps to harvest content from an external source.

Friday, October 11, 2019

Install DSpace 6.x on Debian 9 (Stretch)

Installation of prerequisite applications
Open  Applications > Accessories > Terminal and execute the following commands. Apply following commands,

sudo apt update
sudo apt upgrade
sudo apt install leafpad openjdk-8-jdk ant maven postgresql

Thursday, October 10, 2019

Install DSpace 6.x on Ubuntu 16.04 LTS

Installation of prerequisite applications
Open  Applications > Accessories > Terminal and execute the following commands. Apply following commands,

sudo apt update
sudo apt upgrade
sudo apt install leafpad openjdk-8-jdk ant maven

Thursday, November 2, 2017

Edit news in XMLUI front page


Open a Terminal and apply the following command to open the news file;

leafpad /dspace/config/news-xmlui.xml

Change the new content.
If you wish to add hyperlink of any website, please see the script beloow,

<xref target="https://mgucat.mgu.ac.in"><head>Online Catalogue</head></xref>

Save and close the file. Then see the changes in Dspace XMLUI interface.

Tuesday, October 31, 2017

http status 404


If Dspace shows the error of "http status 404", it means that Tomcat user has no permission to make changes in Dspace folders. 

The lack of Tomcat user  on Dspace folders can also generate problem of reluctant to upload the documents.

Solution
We need to give the permission to the Tomcat user to access Dspace folders, upload and assetstore. First find the Tomcat user name in the Dspace computer. My Tomcat user name is tomcat. Then assign all permissions to write changes in the folders. Open a Terminal and apply following commands:

sudo su
chown -R tomcat /dspace/upload 
chown -R tomcat /dspace/assetstore

Thursday, October 19, 2017

Customise the logo of XMLUI interface

Prepare a logo as follows (125x74 pixel). Here image format is PNG.

Place the image in home folder (e.g. /home/vimal).
Open a Linux Terminal and apply following command to copy the logo image to the folder.

cp logo.png /opt/tomcat/webapps/xmlui/themes/Mirage/images

Open the css file to change the logo image attribute. Open a terminal and apply following command. Here Dspace webapps directory located in /opt/tomcat/. Dspace webapps may be located in /dspace folder. Confirm it before the execution of the below command;

leafpad /opt/tomcat/webapps/xmlui/themes/Mirage/lib/css/style.css

Find the following portion from the file.

change the width and height of the logo. Change the logo name.
Go to the Dspace XMLUI home page and refresh the browser.


Saturday, April 22, 2017

Install DSpace 5.x on Ubuntu 16.04 LTS

Installation of prerequisite applications
Open  Applications > Accessories > Terminal and execute the following commands. Apply following commands,

sudo update
sudo apt upgrade
sudo apt install leafpad openjdk-8-jdk ant maven