simple sogo backup in perl with mysql


Need to export(backup) your sogo users contacts calendar etc?

Here some simple approach to get this done.

use warnings;
use DBI;

my $db ="databasename";
my $user = "username";
my $pass = "mypassword";
my $host = "localhost";
my $query = "SELECT mail FROM sogo_users";
my $bkppath = "/path/to/backup";
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);

my $dbh = DBI->connect("DBI:mysql:$db", "$user", "$pass")
	or die "Could not connect to database: " . DBI->errstr;

my $sth = $dbh->prepare("$query")
	or die "Couldn't prepare statement: " . $dbh->errstr;

	or die "Couldn't execute statement: " . $sth->errstr;

while ($data = $sth->fetchrow_array()) {
	my $mail = $data;
	my $bkp = `/usr/sbin/sogo-tool backup $bkppath $mail > /dev/null`;
	sleep 2;
	my $mv = `/bin/mv $bkppath/$mail $bkppath/$mail.$wday`;


Have fun!

apache2 reverseproxy for single virtualhost


need to reverseproxy a webite with apache?
following config for following scenario:

your webserver A is running on ip with
but you want that webserver B running proxying to webserver A

then put the following config in your configuration file of webserver B:

<VirtualHost *:80>
         <Proxy *>
                Order deny,allow
                Allow from all
         ProxyPreserveHost On
         ProxyPass /
         ProxyPassReverse /

If you are wondering what the option “ProxyPreserveHost” is read here:
http://httpd.apache. … ml#proxypreservehost
don’t forget to change dns settings.

Have fun!

running tor with optimal configuration

I just didn’t know what to do with my 8Mbit/s symetric fibre flat internet connection
I decided to run a tor middleman node.

So I tried to set it up with best conscience, using a webserver to serve the tor-exit-notice.html , using a reverse dns entry which is forward resolveable and using the offical tor debian repositorys for the tor binary.

I installed debian squeeze on a alix2c1 using debootstrap:

Here my tor config

vim /etc/tor/torrc
# this should force tor to avoid disk writes because of the cf flash card
AvoidDiskWrites 1
#because (i love centralized syslogging)
Log notice syslog
#start tor as daemon
RunAsDaemon 1
# data dir
DataDirectory /var/lib/tor
# i like to graph some tor statistik for debugging with munin (nice to have it)
ControlPort 9051
# needed for authentification for the munin plugins
HashedControlPassword 16:blablablabla
# Required: what port to advertise for incoming Tor connections.
ORPort 9001
# A handle for your relay, so people don't have to refer to it by key.
Nickname TorTorToriweanarisch
# Define these to limit how much relayed traffic you will allow.
RelayBandwidthRate 600 KB
RelayBandwidthBurst 650 KB
# the next two options say that tor is allowed to use only 10GB per day starting from 00:00 localtime
AccountingMax 5 GB
AccountingStart day 21:00
# this info is very useful, tor will contact you if something is misconfigured or that youre generating ther errors on the network
ContactInfo Tor Ture <paranoid dot brume AT gmail dot com>
#This setting means that your relay will be used for relaying traffic inside the Tor network, but not for connections to external websites or other services
ExitPolicy reject *:*

Here some references (please read):
https://blog.torproj … rg/running-exit-node
https://trac.torproj … oc/ReducedExitPolicy
https://www.torproje … html.en#ExitPolicies

Generate your password hash for control connection:

tor --hash-password password

That’s it
Have fun!