Cleaning and updating remote instances of standalone

Login to standalone server. Stop the zeprs service if it is running:

service zeprs stop

Check again that it is not running:

ps ax|grep java

If it is running, note the process id for the java process and kill it:

kill -9 (process id)

Enter the following commands to make a local connection to the database and clean it out. This will delete all of the records in the database and reset the autoincrement id's.

export DERBY_HOME=/var/www/zeprs_standalone/derby-bin
cd /var/www/zeprs_standalone/databases/scripts
/var/www/zeprs_standalone/derby-bin/ij local_conn_clean_db.sql > out.txt

Once this script has completed, review the file out.txt for any errors.

more out.txt

Indications of success:

ij> DELETE FROM problabor;
2 rows inserted/updated/deleted

or

ij> DELETE FROM anteultrasoundeval;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.

Indications of failures:
Look for errors that indicate  that the script was unable to delete records due to foreign key conflicts.. Make sure that pregnancy and patient tables have successfully deleted their records - this is of the utmost importance.

You may either page though out.txt:

more out.txt

or just check that patient and pregnancy have been cleared out:

more out.txt|grep patient -A1
more out.txt|grep pregnancy -A1

There is also a version of clean_db that makes a network connection to the derby database. This is useful if the server is currently running; however, the author recommends running the script when the app is not running and using the local connection.

You may also check counts for each table to confirm using scripts/table_counts.sql. This script makes a local connection to derby. Modify the connection string at the top of the script if you need to make a network connection.

/var/www/zeprs_standalone/derby-bin/bin/ij table_counts.sql > counts.txt

more counts.txt

Some of the user and site tables will have records. The author assumes you don't wish to delete records from these

tables:

  • SITE
  • USER_GROUP
  • USER_GROUP_MEMBERSHIP
  • USER_GROUP_ROLE
  • USER_INFO

Once you have confirmed that the derby database is clean, start zeprs

service zeprs start

Go to Form Admin and click "Clean Archive directories."

Link to clean archive dirs

Next you should compact the database:

Link to view/compact derby db

 

Note the large table sizes on the right side of the screenshot. Click link to Compact the database.

Listing of db sizes showing large table sizes

 

Result of compacting process - note zero-sized tables:

Result of db compacting.

 

Next, click the link to Backup the database:

Link to backup db

Result of backup operation displays the backup location:

Display of Backup location

Listing of files in backup directory:

Listing of backup directory

 

Go to the master app (the ZEPRS server) and copy the url for the RSS feed for the site by going to Admin/Publisher Setup and scroll to the listing of site RSS feeds.

RSS feed link highlighted

Copy the url of the standalone site's feed.

Context menu for copying RSS url

On the standalone app, go to Admin/Subscriptions and paste in the url of the feed:

http://192.168.20.6:8080/archive/KAL/rss.xml

Input box for feed subscription

After saving the subscription, click Import:

Import feed link

The system then returns a page that shows the "Import" link having changed to an "Update" link. In the background, the system is now importing patient records.

Link to update feed

From the console, monitor progress of the import on the standalone

/root/tomtail.sh  (a script that has tail -f /path-to-tomcat/logs/catalina.out)