Start H2 Db as daemon

Here my script to start H2 db as daemon under linux Os.
Please note param “-baseDir $HOME” this means that default storage path is the home of the user that start db,
change variable with absolute path to prevent new Db creation with wrong users.

 
#!/bin/sh

cd `dirname ${0}`/..

case $1 in
  help)
    java -cp <h2Path>/h2-*.jar org.h2.tools.Server -?
  ;;

  start)
    java -cp <h2Path>/h2-*.jar org.h2.tools.Server -tcp -web -baseDir $HOME &
  ;;

  stop)
    java -cp <h2Path>/h2-*.jar org.h2.tools.Server -tcpShutdown "tcp://localhost"
  ;;

  *)
    echo "Usage ${0} (help|start|stop)"
  ;;
esac

Db2 set online logs and enable autodelete for logs and backup

A simple script to set logs for online backup :

 


#!/bin/sh

#First of all create archive logs dir in the home path of the instance owner.
mkdir -p /$HOME/archiveLog

#Change log settings.
db2 UPDATE DB CFG FOR $1 USING logarchmeth1 "DISK:/data/archiveLog" logprimary 15 logsecond 15 logfilsiz 8000

#Backup Db.
db2 BACKUP DATABASE $1 TO "/backup/db2";

#Update log and backup retention (I set to 2).
db2 update db cfg for $1 using rec_his_retentn 2

#Enable auto delete.
db2 update db cfg for $1 using auto_del_rec_obj on

#I setup backup to maintain the last 2 backup.
db2 update db cfg for $1 using num_db_backups 2

You can copy and paste in a script named “setLogs” give grant and run by instance owner:

./setLogs DatabaseName