Thursday, January 22, 2026

Schedule Restart ​PM2 Service for DSpace 9.2 on Ubuntu

Start Manually

pm2 start /home/dspace/dspace-angular-dspace-9.2/dspace-

ui.json

 

Find PM2 binary path

which pm2

Add DAILY restart job (example: 2:00 AM)

 crontab -e 

0 2 * * * /usr/bin/pm2 restart /home/dspace/dspace-angular-dspace-9.2/dspace-ui.json >> /home/dspace/pm2-restart.log 2>&1

 

Ensure PM2 starts on reboot

pm2 startup

pm2 save


Wednesday, January 21, 2026

Schedule Backup of DSpace 9.2 on Ubuntu

Start Manually 

Backup the PostgreSQL Database

Create a dedicated backup folder

sudo mkdir -p /backup/dspace

sudo chown -R dspace:dspace /backup/dspace

Backup Postgres DB

sudo -i -u postgres

pg_dump -Fc dspace > /backup/dspace/dspace_$(date +%F).dump

exit

cd /dspace

tar -czvf /backup/dspace/assetstore_backup_$(date +%F).tar.gz assetstore
-----------------------------------------------------------------------------------------------------------------------------
SCHEDULE YOUR DSpace 9 BACKUP on UBUNTU
-----------------------------------------------------------------------------------------------------------------------------

Step 1: Create Backup Script

sudo nano /usr/local/bin/dspace_backup.sh

---------------------------------copy text--------------------------------------
#!/bin/bash

# Date
DATE=$(date +%F)

# Paths (CHANGE if needed)
DSPACE_DIR=/dspace
BACKUP_DIR=/backup/dspace/$DATE
DB_NAME=dspace
DB_USER=postgres

# Create backup folder
mkdir -p $BACKUP_DIR

echo "Starting DSpace backup: $DATE"

# 1. Database Backup
sudo -u postgres pg_dump -Fc $DB_NAME > $BACKUP_DIR/dspace_db.dump

# 2. Assetstore Backup
tar -czf $BACKUP_DIR/assetstore.tar.gz $DSPACE_DIR/assetstore

# 3. Config Backup
tar -czf $BACKUP_DIR/config.tar.gz $DSPACE_DIR/config

# 4. Themes (optional but recommended)
tar -czf $BACKUP_DIR/themes.tar.gz $DSPACE_DIR/webapps

# 5. Cleanup old backups (keep last 7 days)
find /backup/dspace/* -maxdepth 0 -type d -mtime +7 -exec rm -rf {} \;

echo "DSpace backup completed successfully"

---------------------------------copy text---------------------------------

Step 2: Make Script Executable

sudo chmod +x /usr/local/bin/dspace_backup.sh

Test manually:

sudo /usr/local/bin/dspace_backup.sh

Step 3: Schedule Backup using CRON

sudo crontab -e

0 2 * * * /usr/local/bin/dspace_backup.sh >> /var/log/dspace_backup.log 2>&1

(This will schedule a daily backup at 2:00 AM)

Wednesday, September 3, 2025

Upgrade Koha from 23 to 25

sudo mysql -uroot -p koha_library < koha_library.sql     

sudo systemctl restart apache2.service

sudo systemctl restart koha-common

sudo apt update && sudo apt upgrade

sudo rm /etc/apt/sources.list.d/koha.list

echo "deb http://debian.koha-community.org/koha stable main" | sudo tee /etc/apt/sources.list.d/koha.list

wget -q -O- https://debian.koha-community.org/koha/gpg.asc | sudo apt-key add -

sudo apt update

sudo apt full-upgrade

sudo systemctl restart koha-common

sudo systemctl restart apache2

sudo koha-upgrade-schema library

service mysql restart

sudo systemctl restart apache2

sudo koha-plack --enable library

sudo koha-plack --start library

sudo service memcached restart


Wednesday, December 4, 2024

Create Superuser in Mysql

Login MySQL using
mysql -u root -p
CREATE USER 'superuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'superuser'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit;


Friday, July 5, 2024

How to improve ubuntu performamce

 Here I have involved some steps which may helpful to optimize your Ubuntu server speed.

 

1. Update Your System

Regularly update your system to ensure you have the latest performance improvements and security patches.

 sudo apt update

sudo apt upgrade

 2. Remove Unnecessary Start-up Applications

 Disable unnecessary startup applications to reduce boot time and free up system resources.

 sudo apt install gnome-tweak-tool

gnome-tweaks

 Navigate to the "Startup Applications" section and disable unnecessary programs.

 3. Use Lighter Desktop Environments

If you are using a resource-heavy desktop environment like GNOME or KDE, consider switching to a lighter one like XFCE or LXDE.

 sudo apt install xfce4

sudo apt install lxde

 4. Manage Swappiness

Adjust the swappiness value to reduce the use of the swap file and improve performance.

 sudo sysctl vm.swappiness=10

sudo nano /etc/sysctl.conf

Add or edit the line vm.swappiness=10 in /etc/sysctl.conf.

 5. Clean Up Your System

Remove unnecessary files and packages to free up space and reduce clutter.

 sudo apt autoremove

sudo apt clean

sudo apt autoclean

 Use a tool like BleachBit to clean up system files.

 sudo apt install bleachbit

sudo bleachbit

 6. Optimize Disk Usage

Use tools like fsck to check and repair file system errors.

 sudo fsck /dev/sdX

Use fstrim to trim SSDs.

sudo fstrim -v /

 7. Use a Faster DNS Server

Changing your DNS server can improve network performance. Consider using a faster DNS provider like Google DNS or OpenDNS.

 sudo nano /etc/resolv.conf

Add the following lines:

 nameserver 8.8.8.8

nameserver 8.8.4.4

8. Upgrade Hardware

Adding more RAM or upgrading to an SSD can significantly improve system performance.

9. Disable Animations

Disabling animations can make your desktop environment feel snappier.

gsettings set org.gnome.desktop.interface 

enable-animations false

10. Monitor System Resources

Use system monitoring tools to keep an eye on resource usage and identify bottlenecks.

 sudo apt install htop

htop

 11. Use Lightweight Applications

Use lightweight alternatives to resource-heavy applications (e.g., using Featherpad instead of Gedit).

 12. Kernel Optimization

 Use a low-latency kernel if you're doing audio production or other real-time tasks.

 sudo apt install linux-lowlatency

 

Courtesy: ChatGPT


Monday, April 8, 2024

How to migrate Linux Dspace to Window 10

Take a backup of Dspace database and folders

Assume the version is same with both OS [I have tested DSpace 6.3]

sudo su

mkdir dspace_backup

sudo chmod 777 dspace_backup

exit

dspace_backup/backup.sh

Copy below script to backup.sh file

nano /home/dspace/dspace_backup/backup.sh

#!/bin/bash

PGPASSWORD="dspace" pg_dump -U dspace -h localhost -Fc dspace | gzip > home/dspace/dspace_backup/dspace-$(date +%Y-%m-%d-%H.%M.%S).sql.gz

now=$(date +"%d_%m_%Y")

zip -r  /home/dspace/dspace_backup/$now-assetstore.zip /dspace/assetstore

zip -r  /home/dspace/dspace_backup/$now-log.zip /dspace/log

save the file &

Give a permission to file

sudo chmod +x dspace_backup/backup.sh

Go to directory

cd /home/dspace/dspace_backup

Issue the command

sh backup.sh

copy all files from the directory to Window10

(there will be three files sql.gz, assetstore.zip, and log.zip)

Locate all backup of Dspace database and folders anywhere you wish.

No go to Window Tomcat server and stop its service by

stop tomcat sever











Go to start-up button and open PGAdmin-III 

bellow box will appeared 


create new database [dspace] and also create [pgcrypto] Extension also

Now click on database tab and restore dspacesql (gz) file where you have located your .gz file











after restoring dspace db

delete [assetstore] directory from C:/dspace/

copy new assetstore directory to C:/dspace/

then issue the following command in Window machine

open cmd

Go to 

cd C:\dspace\bin\

dspace database info

dspace database migrate

dspace index-discovery -b

dspace filter-media

dspace index-discovery

dspace index-discovery -o

Then restart Tomcat in Window-10

Now check your backup is fully restored http://yourIP:8080/jspui

If you need any further help please book your slot: Here

or Call me 9428415401





Monday, February 5, 2024

Installing Koha 23.05 on ubuntu

apt update
sudo apt-get -y install sudo wget gnupg
wget -q -O- https://debian.koha-community.org/koha/gpg.asc | sudo apt-key add -
sudo apt-get update
echo 'deb http://debian.koha-community.org/koha stable main' | sudo tee /etc/apt/sources.list.d/koha.list    
sudo apt-get update
sudo apt-get install koha-common
sudo apt-get install mysql-server 
sudo nano /etc/apache2/ports.conf
change INTRAPORT to 8080
Listen 80
Listen <staff interface port number> i.e. 8080
sudo nano /etc/koha/koha-sites.conf
sudo a2enmod rewrite 
sudo a2enmod cgi 
sudo service apache2 restart
sudo service apache2 restart 
sudo koha-create --create-db library
sudo nano /etc/apache2/sites-enabled/000-default.conf
sudo service apache2 restart 
To Know the koha_library password
sudo koha-passwd library
http://IP-Domain name:8080 (staff)
http://IP-Domain (OPAC)

Tuesday, March 7, 2023

If Node Version Manager (nvm) does not install in Ubuntu

 Manual Install

export NVM_DIR="$HOME/.nvm" && (

  git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR"

  cd "$NVM_DIR"

  git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)`

) && \. "$NVM_DIR/nvm.sh"

-------------------------------------

export NVM_DIR="$HOME/.nvm"

[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion


------------------------------------

(

  cd "$NVM_DIR"

  git fetch --tags origin

  git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)`

) && \. "$NVM_DIR/nvm.sh"

----------------

nvm install 16.18.1

Sunday, January 29, 2023

Installing DSpace 6.x on Ubuntu/Debian

Software Requirements

Software needed to run DSpace.

  • Java JDK 8
  • Apache Maven
  • Apache Ant
  • PostgreSQL
  • Apache Tomcat


Create User

Create a dspace user.


sudo useradd -m dspace

sudo passwd dspace


Install PostgreSQL

Install PostgreSQL database.


sudo apt install postgresql postgresql-client -y


Create a dspace user with a dspace password in PostgreSQL.


sudo su postgres

createuser -U postgres -d -A -P dspace

exit


Create a dspace database .


sudo -u dspace createdb -U dspace -E UNICODE dspace


Activate the pgcrypto extension.


sudo su postgres

psql --username=postgres dspace -c "CREATE EXTENSION pgcrypto;"

exit


Open the PostgreSQL configuration file.


sudo nano /etc/postgresql/12/main/pg_hba.conf


Add the following line at the bottom of the configuration.


local  all  dspace  md5


Restart PostgreSQL.


sudo systemctl restart postgresql

sudo systemctl status postgresql


Building DSpace

Install OpenJDK 8.


sudo apt install openjdk-8-jdk -y


If you have previously installed another version of OpenJDK, change the default java to OpenJDK 8.


sudo update-alternatives --config java


Install ant and maven.


sudo apt install ant maven -y


Create a dspace folder.


sudo mkdir /dspace

sudo chown dspace /dspace


Create a build folder for building DSpace.


sudo mkdir /build

sudo chmod -R 777 /build

cd /build



wget https://github.com/DSpace/DSpace/releases/download/dspace-6.3/dspace-6.3-src-release.tar.gz


Extract dspace*.tar.gz


sudo tar xzvf dspace*.tar.gz


Move to the dspace-6.3-src-release folder


cd dspace-6.3-src-release


Copy the local.cfg file.


sudo cp dspace/config/local.cfg.EXAMPLE dspace/config/local.cfg


Compile the DSpace package.


sudo mvn -U package


Install DSpace.


cd dspace/target/dspace-installer

sudo ant fresh_install


Install Apache Tomcat

Download and extract Apache Tomcat 9.


cd /opt


wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.71/bin/apache-tomcat-9.0.71.tar.gz


sudo tar xzvf apache-tomcat-9.0.71.tar.gz


Change the apache-tomcat-9.0.41 folder to tomcat.


sudo mv apache-tomcat-9.0.71 tomcat


Open the file /etc/profile.


sudo nano /etc/profile


Add these lines at the bottom, configuration environment variables for Java.


export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

export CATALINA_HOME=/opt/tomcat


Copy dspace webapps to tomcat webapps.


sudo cp -r /dspace/webapps/* /opt/tomcat/webapps


Create a bash script so that Tomcat can run automatically.


sudo nano /etc/init.d/tomcat


Enter the following bash script.


#!/bin/bash

### BEGIN INIT INFO

# Provides:        tomcat9

# Required-Start:  $network

# Required-Stop:   $network

# Default-Start:   2 3 4 5

# Default-Stop:    0 1 6

# Short-Description: Start/Stop Tomcat server

### END INIT INFO


PATH=/sbin:/bin:/usr/sbin:/usr/bin


start() {

 sh /opt/tomcat/bin/startup.sh

}


stop() {

 sh /opt/tomcat/bin/shutdown.sh

}


case $1 in

  start|stop) $1;;

  restart) stop; start;;

  *) echo "Run as $0 <start|stop|restart>"; exit 1;;

esac


Give it executable permissions and set it as service.


sudo chmod +x /etc/init.d/tomcat

sudo update-rc.d tomcat defaults


Run Tomcat server and check its status.


sudo service tomcat start

sudo service tomcat status


DSpace Administrator


Create a DSpace administrator account.


sudo /dspace/bin/dspace create-administrator


Delete the builds folder.


sudo rm -rf /build


DSpace access test.


http://localhost:8080/xmlui or http://serverIP:8080/xmlui

http://localhost:8080/jspui or http://serverIP:8080/jspui

Friday, December 2, 2022

How to automatically reboot Ubuntu 22.04

 

Schedule reboots in the Ubuntu


launch a terminal

Type sudo su

sudo crontab -e and then press ENTER

Then 

Add the below line 

00 09   *   *   *    /sbin/shutdown -r +5

Press CTRL+X, then Y, then ENTER.

Your ubuntu server automatically restarts at 9:05am daily

Monday, August 29, 2022

Installing Koha 22.05 on Ubuntu 20.04 LTS

sudo apt-get update

sudo apt upgrade

sudo apt clean

sudo apt-get -y install sudo wget gnupg2

 sudo sh -c 'wget -qO - https://debian.koha-community.org/koha/gpg.asc | gpg --dearmor -o /usr/share/keyrings/koha-keyring.gpg'

echo deb http://debian.koha-community.org/koha 22.05 main | sudo tee /etc/apt/sources.list.d/koha.list

wget -O- http://debian.koha-community.org/koha/gpg.asc | sudo apt-key add -

sudo apt update

 sudo apt install -y mariadb-server

 sudo mysqladmin -u root password (******)

 

sudo apt install -y koha-common

 

sudo nano /etc/koha/koha-sites.conf

 

 update INTRAPORT from '80' to 8080

 

INTRAPORT="8080"

 

sudo a2enmod rewrite

 

sudo a2enmod cgi

 

sudo service apache2 restart

 

sudo koha-create --create-db library

 

sudo nano  /etc/apache2/ports.conf

 

Edit ports.conf & add port 8080

 

 Listen 80

Listen 8080

 

 sudo service apache2 restart

 

sudo a2dissite 000-default

 

sudo a2enmod deflate

 

sudo a2ensite library

 

sudo service apache2 restart

 

 To view the (koha_library) admin user password

 sudo koha-passwd library

 

Tuesday, July 12, 2022

Extract .xz files on Linux (ubuntu)

sudo apt update

sudo apt install xz-utils

unxz file.xz

In my case, I have a file koha_library.sql.xz

unxz koha_library.sql.xz

Search text in nano editor in Ubuntu Linux

Edit file in Nano

Press CTRL + W or F6   

Than Enter

Thursday, January 13, 2022

To edit any files with SFTP or FTP with normal user (ubuntu 20.04)

 The following commands are allowed to edit on SFTP/FTP

sudo find /etc/koha/ -type d -exec chmod 777 {} \;

sudo find /etc/koha/  -type f -exec chmod 666 {} \;














Monday, January 10, 2022

Open port on ubuntu 16.04/20.04 LTS

 Open terminal [ctrl+T] and hit 


sudo ufw status

Apache Full                ALLOW       Anywhere
22                         ALLOW       Anywhere
3306                       ALLOW       161.202.20.0/24
3306 on eth1               ALLOW       Anywhere
3306                       ALLOW       Anywhere
Apache Full (v6)           ALLOW       Anywhere (v6)
22 (v6)                    ALLOW       Anywhere (v6)
3306 (v6) on eth1          ALLOW       Anywhere (v6)
3306 (v6)                  ALLOW       Anywhere (v6)
There is no 8080 port in above list
Now allow 8080 port 
sudo ufw allow

Tuesday, November 16, 2021

DSpace Autobackup

 #!/bin/bash

PGPASSWORD="dspace" pg_dump -U dspace -h localhost -Fc dspace | gzip > dspace_backup/dspace-$(date +%Y-%m-%d-%H.%M.%S).sql.gz

now=$(date +"%d_%m_%Y")

zip -r  /home/koha/dspace_backup/$now-assetstore.zip /dspace/assetstore

Friday, July 9, 2021

Installing Tomcat

cd /opt && sudo wget https://mirrors.estointernet.in/apache/tomcat/tomcat-9/v9.0.50/bin/apache-tomcat-9.0.50.tar.gz


sudo tar xvzf apache-tomcat-9.0.50.tar.gz

sudo mv apache-tomcat-9.0.50 tomcat

sudo gedit /etc/profile

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export CATALINA_HOME=/opt/tomcat

 

sh /opt/tomcat/bin/shutdown.sh

sh /opt/tomcat/bin/startup.sh

  



Friday, February 12, 2021

Import large sql file in Phpmyadmin on Ubuntu 20.04 (Debian9)

If try to import large SQL (MySqL) file and take long lime or fail to work.

Try the bellow steps:

Create an 'Upload' and a 'save' directories for PhpMyadmin

mkdir /etc/phpmyadmin/upload 

mkdir /etc/phpmyadmin/save 

chmod a+w /etc/phpmyadmin/upload 

chmod a+w /etc/phpmyadmin/save

Then edit phpmyadmin's config file: 

sudo nano /etc/phpmyadmin/config.inc.php

add absolute path for both 'upload' and 'save' directories:

$cfg['UploadDir'] = '/etc/phpmyadmin/upload'; 

$cfg['SaveDir'] = '/etc/phpmyadmin/save';

$cfg['Servers'] [$i] ['LoginCookieValidity'] = 72000;

Now copy the koha_library.sql file to [/etc/phpmyadmin/upload]

cp /your koha_library.sql file/   /etc/phpmyadmin/upload/

sudo chmod 777 /etc/phpmyadmin/upload/koha_library.sql


Timeout error in phpMyAdmin during import database from file

and 

Open (search code using F6 in nano editor)

nano /usr/share/phpmyadmin/libraries/config.default.php

$cfg['ExecTimeLimit'] = 300; Make it to

$cfg['ExecTimeLimit'] = 0;

Restart Apache2 

service apache2 restart


                                                           

Thursday, February 11, 2021

How do I uninstall MySQL completely from ubuntu/Debian

sudo -i

service mysql stop


killall -KILL mysql mysqld_safe mysqld


apt-get --yes purge mysql-server mysql-client


apt-get --yes autoremove --purge


apt-get autoclean


deluser --remove-home mysql


delgroup mysql



sudo rm -rf /var/lib/mysql 

 

sudo apt-get remove --purge *mysql\*


sudo apt-get autoremove


sudo apt-get autoclean 




Tuesday, January 12, 2021

MySQL Autobackup of Koha in Debian/Ubuntu


I am showing you the easiest way to keep automate your koha db backupthat is the combination of MySQL Dumps and a cronjob.

Create a file called mysqldump.sh

mkdir /home/debian/backup/mysqldump.sh

copy the bellow line.

mysqldump -uroot -p******* koha_library | gzip > /home/debian/backup/koha_`date +%F`.sql.gz

save it

Test the script

 chmod +x /home/debian/backup/mysqldump.sh

Create and schedule a new cron job

Execute the script:

 sh /home/debian/backup/mysqldump.sh

And add the following line at the bottom of crontab -e

 30 23 * * * /home/debian/backup/mysqldump.sh

(This will execute the script every day at 23:30.)

------------------------------PERIODIC REMOVAL OF FILES--------------------------

tested on Debian/UBUNTU

  nano /home/debian/backup/mysqldump.sh

Add the line at the end: (this script will remove your Koha backfiles after 7 days)

  find /home/debian/backup/koha* -type f -mtime +7 -exec rm {}

--------------------------Auto Restart Mysql service------------------------------------------

And add the following line at the bottom of crontab -e 

30 23 * * * systemctl is-active  || systemctl start mysql.service

This will run every midnight at 11.30PM



Schedule Restart ​PM2 Service for DSpace 9.2 on Ubuntu

Start Manually pm2 start /home/dspace/dspace-angular-dspace-9.2/dspace- ui.json   Find PM2 binary path which pm2 Add DAILY resta...