A chronological documentation test project, nothing serious, really!

09 Feb 2020 Modify Rspamd throughput (RRD) graph

This short post describes how to remove data from Rspamd throughput RRD-graph, usually stored in the rspamd.rrd file. The location depends on the linux distribution, but it is located /var/lib/rspamd/rspamd.rrd on Ubuntu 18.04.

This procedure can most likely be used on all types of RRD-files and is not exclusive for Rspamd.

It is recommended to stop the Rspamd daemon and make a backup of your rspamd.rrd file before you continue.


$ sudo systemctl stop rspamd.service
$ sudo cp -ax /var/lib/rspamd/rspamd.rrd /var/lib/rspamd/rspamd.rrd-$(date -I)

We have now created a backup file of our RRD-file.

Dump RRD-file

Next we need to create a dump of the RRD-file to a XML-file before we can do any modifications on the data.

$ sudo rrdtool dump /var/lib/rspamd/rspamd.rrd /tmp/rspamd.rrd.xml

Structure of the RRD-file

The Rspamd file is the basis for the graphs and are ordered in archives based on the datasets By day, By week, By Month and By year and you will find the same structure in the rrd-file if you search for 60, 300 600 or 3600 seconds.

    <!-- Round Robin Archives -->
            <pdp_per_row>60</pdp_per_row> <!-- 60 seconds -->
            <pdp_per_row>300</pdp_per_row> <!-- 300 seconds -->
            <pdp_per_row>600</pdp_per_row> <!-- 600 seconds -->
            <pdp_per_row>3600</pdp_per_row> <!-- 3600 seconds -->


The XML-file of the RRD-file is now stored in /tmp/rspamd.rrd-xml and can be edited with your preferred editor.

I removed several months of empty data points by searching them up and deleting the lines I did not want.
The values I deleted were inside the <database> tags like this

                    <!-- 2019-02-08 23:00:00 CET / 1549663200 --> <row><v>NaN</v><v>NaN</v><v>NaN</v><v>NaN</v><v>NaN</v><v>NaN</v></row>
                    <!-- 2019-02-09 00:00:00 CET / 1549666800 --> <row><v>NaN</v><v>NaN</v><v>NaN</v><v>NaN</v><v>NaN</v><v>NaN</v></row>
                    <!-- 2019-02-09 01:00:00 CET / 1549670400 --> <row><v>NaN</v><v>NaN</v><v>NaN</v><v>NaN</v><v>NaN</v><v>NaN</v></row>
                    <!-- 2019-02-09 02:00:00 CET / 1549674000 --> <row><v>NaN</v><v>NaN</v><v>NaN</v><v>NaN</v><v>NaN</v><v>NaN</v></row>

Restore RRD-file

Restore the modified RRD-file and start rspamd

$ sudo rm -f /var/lib/rspamd/rspamd.rrd && \
rrdtool restore -f /tmp/rspamd.rrd.xml /var/lib/rspamd/rspamd.rrd && \
chown _rspamd:_rspamd /var/lib/rspamd/rspamd.rrd
$ sudo systemctl start rspamd.service

Check if Rspamd complains

$ sudo tail -f /var/log/rspamd/rspamd.log 

You either have wrong file permission og done something wrong with the RRD-file uf you see the following error

2020-02-08 22:51:24 #15878(controller) ; csession; rspamd_controller_handle_graph: no rrd configured

Restore backup

This is the procedure if you made a mistanke and want to restore your backup (you did remember to create a backup before you started?).

Stop rspamd daemon and restore your RRD-backup. I assume you are doing this the same day you created a backup file.

$ sudo systemctl stop rspamd.service
$ sudo cp -ax /var/lib/rspamd/rspamd.rrd-$(date -I) /var/lib/rspamd/rspamd.rrd
$ sudo systemctl start rspamd

Check you rspamd.log and see if you have any error messages

$ sudo systemctl status rspamd.service
$ sudo tail -f /var/log/rspamd/rspamd.log

And thats all.

Tags: , , , , , , ,

Posted by

05 Sep 2014 Backup VMware ESXi using BazaarVCB

This post describes how you can backup your VMware ESXi home installation with free license using BazaarVCB if you do not have a vCenter Server available. Bazaarvcb is the fastest backup solution I have used on the free VMware hypervisor.
Download the latest version from the download page.

The backup script is run by crontab every night and looks like this

vmNames="vm-guest1 vm-guest2 vm-guest3"

for VM in $vmNames; do
        `$bazaarvcbPath backup -H $hostname -u $username -p $password --roll-out $rollOut $VM $backupsPath/$VM`

The backups are full so make sure you have enough disk space available.

bazaarvcb options

$ bazaarvcb -h
usage: bazaarvcb [-h]  ...

optional arguments:
  -h, --help   show this help message and exit

valid commands:
    checkhash  check .hsh files integrity in one directory
    listvm     list registered VMs on the ESXi host
    queryvm    display VMs informations
               search for backups in local and remote directories
               display report file of one particular
    backup     backup a VM
    restore    restore a backup

Open TCP port 31031 in your firewall to ensure that you have a high transfer rate, otherwise the backup will be transferred over SSH protocol and will be capped in speed to about 7MB/s (on the free hypervisor).
Bazaarvcb cannot backup a VM with snapshot(s).

I have not tested this on a host connected to a vCenter server and can not confirm that it will work or not.

Tags: , , ,

Posted by

02 Aug 2012 Backup of Zimbra MailBox using zmmailbox

This is a short script I use to backup the Zimbra mailbox content for my users.
This has been used on a Zimbra Collaboration Server (ZCS Open Source Edition) 7.2 installation, but should work on earlier versions as well.
I use another script to backup the whole Zimbra installation, but that might be another blog post.

#!/bin/bash -x
# Backup of Zimbra mailboxes using zmmailbox
# Restore of mailbox should be performed using:
# /opt/zimbra/bin/zmmailbox -z -m user@host postRestURL -u https://HOST "//?fmt=tgz&resolve=skip" mailbox-name-date.tgz
MailBox="user1 user2 user3 userN"
DateToday=`date -I`
for name in $MailBox
sudo -u zimbra /opt/zimbra/bin/zmmailbox -z -m $ getRestURL "//?fmt=tgz" > mailbox-$name-$DateToday.tgz

The backup files are named mailbox-user1-20120802.tgz mailbox-user2-20120802.tgz …

Tags: , , , , , ,

Posted by

02 Nov 2009 Howto backup mysql stored functions and stored procedures

This is how you can backup you MySQL database(s) and stored procedures

# mysqldump --routines <dbname>

Or you can backup only the stored procedures

# mysqldump --no-create-db --no-create-info --no-data --routines <dbname>

Tags: , , ,

Posted by

19 Mar 2009 Backup partition table

This post describes how you can backup your partition table for future recovery.


This example describes how you can backup the disk partition table on /dev/sda

dd if=/dev/sda of=sda.mbr bs=512 count=1

It’s also useful to keep a human readable copy of the disk layout for future reference

sudo fdisk -l > partitions.lst


This example shows how you can recover your file system using your partition table backup.

dd if=sda.mbr of=/dev/sda bs=512 count=1

This is a nice way to keep the information about your file system and will it help you in the future if you get disk corruption.
This does not only apply to linux partitions but all types of partitions.

Tags: , , ,

Posted by