Regenerating the Cobalt RAQ550 stats

Had to rebuild the webstats for a client on a RAQ550 as for some reason the stats had been corrupted.

The URL to view the stats was: http://www.site.com/stats/

Checking the crontabs showed that there was a script that ran nightly: /etc/cron.daily/webalizer.pl

The script ran through all the sites and built the stats pages for them along with various other things.  The bit we were interested in was:

/usr/local/bin/webalizer -D /home/log/dns.cache -p -n $asite -s $asite -r $asite -q -Q -T -o $thepath $prefix/$asite/logs/web.log

Made a backup of the stats and logs directories with:

mkdir /root/sitestats_backup
tar -cf /root/sitestats_backup /home/sites/www.site.com/logs
tar -cf /root/sitestats_backup /home/sites/www.site.com/web/stats

There were .gz files in the log directory and an empty web.log.  Obviously the web.log file is not populated until the stats program runs later in the day.  Created a combined web.log file in the sites logs directory with:

zcat web.log.3.gz web.log.2.gz web.log.1.gz > web.log.combined

Then, running webalizer:

cd /home/sites/www.site.com/web/stats

/usr/local/bin/webalizer -D /home/log/dns.cache -p -n www.site.com -s www.site.com -r www.site.com -q -Q -T -o /home/sites/www.site.com/web/stats /home/sites/www.site.com/logs/web.log.combined

However, webalizer skipped a lot of entries… so, deleted all the entries in the stats directory (rm *) and then re-ran the command above.  This generated all the stats again without issue.

Plesk backup temporary file filling disk

It appears that the Plesk backup utility (pleskbackup Linux) writes to a temporary file prior to moving it to the final destination you’ve specified on the command line.

ie. When running:

/usr/local/psa/bin/pleskbackup all /mnt/nfsshare/pleskbackup.bak

Plesk writes the whole backup file to the local disk in /var/lib/psa/dumps/tmp/:

# ls -lah /var/lib/psa/dumps/tmp/
total 1.9G
drwx—— 2 psaadm psaadm 4.0K 2009-02-09 18:38 .
drwxr-xr-x 3 psaadm psaadm 4.0K 2009-02-09 10:17 ..
-rw-r–r– 1 root   root   1.9G 2009-02-09 18:44 fileTFzx5u

This is a problem when you’re low on disk space on the machine and you’re mounting a NFS drive to backup to… it obviously fills the disk quickly and the backup fails.

Note:

  • Restoration of the backup files created by the script below has not yet been tested
  • Disk may still fill up due to very large site… may have to symlink the psa tmp directory onto the NFS mount
  • Tested with psabackup from Plesk version 8.2.1
  • It turned out that the site used over 60% of available disk space so filled the disk every time.  Plus, Plesk backup/restore on Linux has known issues for site backup files larger than 2GB in size.  Will have to write a manual backup script to overcome this.

The script looked like below, but, will need to be updated to backup sites too large for pleskbackup to handle.  This may or may not work for you depending on the Plesk version you are using… use at own risk.

#!/bin/bash

dopleskbu () {
MYSQLPASS=`cat /etc/psa/.psa.shadow`
for DOMAIN in `mysql -Ns -uadmin -p$MYSQLPASS -Dpsa -e “select name from domains”`;
do /usr/local/psa/bin/pleskbackup domains $DOMAIN –exclude=DOMAIN_IF_YOU_WANT $FPATH.$DOMAIN.bak;
if [ $? == 0 ]; then
logger “$0 $DOMAIN backup complete”
else
logger “$0 $DOMAIN backup error”
fi
done;
}

FILENAME=pleskbackup.weekly
DIR=/mnt/backup
FPATH=$DIR/$FILENAME

# Main calls

dopleskbu
### END OF SCRIPT ###