MySQL backup db script


You want to back up your mysql database.


This script is good for backups, as it will generate a dump – zipped and as the day of the week is used (in the backup file name), automatically rolls every 7 days.

Run it daily or every other day. If you want a months worth, guess can just change the date command, etc.


#!/bin/zsh[ $# -ne 1 ] && {    echo "Usage: $0 db"    exit 1}db=$1dbd="/PATH_TO_YOUR_BUS/$db.$(/bin/date +%a)"    # set the pathalias mysqldump="/usr/bin/mysqldump"            # you may need to modify thisalias gzip="/bin/gzip"                          # may need to change this too# set your password and usermysqldump --user=root --password=your_password $db > $dbd gzip --best --force $dbdexit 0


Step by step howto – display a warning before leaving site


Sometimes there is an audit requirement, to let customers know a link is off your site and therefore you take no further responsibility for it. For example, a reference to an external associate site.


I’ve just used some simple javascript code, which is triggered by the click (onclick event). This pops up a warning, which can be accepted or rejected. Accepting goes to the desired site, whilst reject just aborts.


Or you can see it in its own page here: demo of accepting to leave a site

Here is the source code of the link:

<script>function Terms() {'/common/demoP/popup.html','windowName','width=500,height=300');    if (!popup.opener) popup.opener = self;}</script>Hi there - below you'll see a link to  When you click it, a popup will appear that you need to accept to follow the link.

<a href="#" onClick="Terms()">

Here is the source of the popup:

<script>function supressError() { return true; }function load(url) { window.onerror = supressError;    opener.location.href = url;}</script>Warning you are about to leave my cool site,
only click 'Leave' if you absolutely want too!<form><input type=submit value="Don't Leave!" onClick="javascript:self.close()"><input type=submit value="Leave" onClick="javascript:load('');self.close()"></form>


Step by step – HowTo implement encryption for Weblogic 6.1 (WLS6.1)


You want to implement encryption between the web server and the backend Weblogic server.


Save yourself the 8 hours it took me to debug this one! 🙂

Handed to you on a plate – clear simple and proven. 😉

Generate a self signed cert as describe in my Generating a self signed cert with openssl

One gotcha is if your WLS has only an export license, which then requires a maximum of 56bits encryption via a 512 byte cert.


Therefore you need to generate the cert like this (2 years):

openssl req -newkey rsa:512 -days 730 -keyout newreq.pem -out newreq.pem

To check if you have an export license,

grep -i export /opt/bea/license.xml

– will show something like this:

license component="SSL/Export" expiration="never …

Another suggested tip by BEA is to ensure the files (cert, key and ca cert) should all end with the extension .pem.

Once you have the new key, cert and your CA cert (default demoCA/cacert.pem), copy it into /opt/bea/wlserver6.1/config/bpmdomain/myserver (or the location where you have Weblogic installed).

In our version we use wlintegration – so our path is /opt/bea/wlintegration2.1/config/bpmdomain/myserver


Subsequently these files are referenced from config.xml as explain below(replace file names with the ones you created and your ca):


For apache to work, need to modify configs to look something like this (after copying your cacert file to location designated below):

...IfModule mod_weblogic.c...WebLogicHost hostnameWebLogicPort 7002SecureProxy OntrustedCAFile yourcafile.pemRequireSSLHostMatch falseConnectTimeoutSecs 60Debug OffErrorPage https://xxxx/outage.html.../IfModule...

Notice the different port (7002) – default Weblogic SSL port. You need to ensure this is open from the firewall.

See my perl perl network connectivity checking tips here
You can use listenport code as well to listen on 7002 on application server, then scanport code to attempt to connect from the web server.

Therefore ensure it will work, even before entering change control! 🙂

– WebLogic Forum at Tek-Tips

Weblogic admin script for command line monitoring


You want to be able to view BEA Weblogic Server status from the command line.


Works beautifully with weblogic 6.1 and wlintegration 2.1 on Solaris – untested with Weblogic 7 or 8, etc.


If your is different, update to correct path – same with password and port (7001).
To obtain the JVM stats, just run it like this:

./wladmin GET -pretty -type JVMRuntime
===================    wladmin script ==========================#!/bin/zsh# script to run command line weblogic stuff[ $# -eq 0 ] && {echo "Usage: $0 CommandExamples:$0 HELP$0 GET -pretty -type Server$0 GET -pretty -type Server$0 GET -pretty -type Security$0 GET -pretty -type WebAppComponent$0 GET -pretty -type WebAppComponent Runtime -property Status$0 GET -pretty -type Application$0 GET -pretty -type Realm$0 GET -pretty -type ServletRuntime$0 GET -pretty -type JVMRuntime$0 GET -pretty -type JDBCConnectionPool$0 GET -pretty -type JDBCConnectionPoolRuntime$0 GET -pretty -type Machine$0 GET -pretty -type Cluster$0 GET -pretty -type ClusterRuntime$0 GET -pretty -type JTA$0 GET -pretty -type JTARuntime$0 GET -pretty -type ExecuteQueue$0 GET -pretty -type ExecuteQueueRuntime"exit 1}. /opt/bea/wlserver6.1/ > /dev/nulljava -cp $CLASSPATH weblogic.Admin -url localhost:7001 -username system -password YOUR_PASSWORD $*exit 0===================    wladmin script ==========================

The HeapFreeCurrent is the value of interest.

Capture can then be automated with a script run by cron, that additionally pumps out the date to correlate timings with stats.