Build driver for Digital Devices Cine CT V6

There is also a complete package if you do not want to roll your own. Unfortunately it does not work with Ubuntu 14.10 as of today.

Getting the drivers for the Digital Devices Cine CT V6 to work is a bit different from 14.04 as there is no prebuilt version in a PPA. So it is back to recompiling from source with every kernel update. Luckily it is fairly easy after I found this post:

It will work with Kernels up to 3.18

Build and install driver for Ubuntu 14.10

First install a few packages. Mercurial to get hg to work, ncurses and the current linux source files needed if you want to only build drivers for your card and deselect the others with make menuconfig.

sudo aptitude install mercurial git libproc-processtable-perl ncurses-dev linux-source
hg clone http://linuxtv.org/hg/~endriss/media_build_experimental
cd media_build_experimental
make download
make untar
./build --check-only
make menuconfig
make
make install

install the firmware for the card (still in the same directory):

experimental/oe/get_dvb_firmware drxk

load the kernel module

modprobe ddbridge
After a kernel update, the drivers need to be rebuilt:
cd media_build_experimental
make distclean
make untar
make menuconfig
make
make install

More information can be found on Digital Devices support page and on vdr-portal.de.

Thanks to Oliver Endriss who made this work!

Limit user to chrooted SFTP access

If you would like to give a user sftp only access and have him chrooted in his own home dir, this is what does the trick:

This has been tested on an Ubuntu 12.04 LTS system.

Add the user as you normally would. Then you need to change the users default shell

# usermod -s /usr/lib/sftp-server
# echo ‚/usr/lib/sftp-server‘ >> /etc/shells

For security reasons the root jail needs to be owned by root itself with the correct mode. Otherwise it will not work and errors get thrown in auth.log.

# chown root:root /home/username
# chmod 755 /home/username

if you want the chrooted user to have write access – which is impossible in the root jail itself you need to create a dropbox

# mkdir /home/username/dropbox
# chown username:usergroup /home/username/dropbox
# chmod 755 /home/username/dropbox

Chrooting and limiting to SFTP

Edit /etc/ssh/sshd_config

Match user username
#Match group groupname
ChrootDirectory %h
ForceCommand internal-sftp
AllowTCPForwarding no
X11Forwarding no

then issue

# sshd -t
# service sshd restart

Kerio Contacts Export Script (.eml to .vcf)

The Kerio Mailserver is a very good product in my eyes. It is easy to administer and offer almost all features needed in a groupware solution: Calendars, email, contacts, shared folders etc. It runs on Mac OS X, Linux and Windows and can operate as an Exchange replacement. It talks to all popular commercial and Open Source Clients such as AppleMail, Thunderbird, Outlook etc.

KMS stores contacts in the public folder as email messages. The body of the message is a V. 3.0 VCard. The following script exports all contacts from the Kerio Mailserver directory to a backup directory, strips the email header and changes the line endings from DOS CR/LF to *nix LF.

  • Change line endings
  • Strip email header
  • Output to new file with .vcf extension

The script is really an quick hack, it does not do any real error checking and stuff, so it can definitely die.
The script has been tested on Mac OS X but should also run on Linux. Don’t know about windoze.

#! /bin/bash 

# kerio_vcard_export.sh
# Version 1.0 Last Updated: December 4th 2006
#
# Software License Agreement
#
# Copyright (C) 2006, Simon Grasser (simeli). http://osiris.simeli.net
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of Simon Grasser nor the names of its contributors
# may be used to endorse or promote products derived from this
# software without specific prior written permission of Simon Grasser.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS „AS
# IS“ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#
###############################################################################
#
# You need to run the script as root to have access to the kerio files.
# The script allows to change the owner of the file to be changed – e.g.
# a non privileged user.
#

DATE=“/bin/date“

# the directory of the contacts you’d like to export
MAILSERVER=’/usr/local/kerio/mailserver/store/mail/company.com/#public/Contacts/#msgs‘

# name of the user whoe should own the exported files
OWNER=“adm“

# the directory in which you’d like to save the contacts
VCARD_DIR=’/Users/adm‘

#
# Nothing needs to be edited below this line
#

# the name of the folder in which we put the backup
# formatted with the date and time of the backup
VCARD_FOLDER=“KerioVCardBackup.`$DATE +%Y%m%d%H%M`“

# Making backup directory $VCARD_FOLDER/tmp
mkdir -p $VCARD_DIR/$VCARD_FOLDER/tmp

cd $MAILSERVER

# copy all contact files to the backup directory
cp *.eml $VCARD_DIR/$VCARD_FOLDER/tmp

# loop over all contact files in backup temp directory
cd $VCARD_DIR/$VCARD_FOLDER/tmp
for vcard in *.eml
do
echo „processing $vcard : change CR/LF, strip header“

# change DOS CR/LF to *nix line endings and strip the header of the message
# then output the „correct“ VCards to the backup directory
sed -e ’s/.$// ; 1,/^$/ d‘ <$vcard | iconv -f UTF8 -t MACROMAN > $VCARD_DIR/$VCARD_FOLDER/${vcard/%eml/vcf}
done;

# remove temporary files
rm -rf $VCARD_DIR/$VCARD_FOLDER/tmp

# change owner of the exported files
chown -R $OWNER $VCARD_DIR/$VCARD_FOLDER

System Backup Script with tar

While BackupPC with it’s web interface is certainly a nice thing to have it imposes a few problems if you want to use it to backup your system. Bare metal restores are more tricky, because files are stored in a proprietary format. Hence you will need to set up BackupPC before you can restore your system, something that is not so trivial.
I looked into another system that would allow me to create a backup of my system completely automated and that would allow for simple bare metal restores. I ended up using tar, as it is a proven tool and is supported even on the most basic live distro you’ll find.
I wrote a small shell script that gives me a few options:

  • backup the master boot record
  • let exclude certain directories from my backup
  • keep defined number of versions of my backup

My entire system backed up like this ends up in a tarball of about 1.8GB.

#!/bin/bash#backup script

#check if you are root
if [ $(whoami) != ‚root‘ ]; then
echo „Must be root to run $0″
exit 1;
fi

#base dir to store backup tarball
DIRECTORY=“/path/to/backup“
DATE=`date +%Y%m%d`

#files to exclude
#exclude dynamically created system directories such as /dev or /sys and any other dirs
#you don’t want to include
#also exclude the backup dir
EXCLUDES=(/dev /home /lost+found /media /mnt /proc /sys $DIRECTORY)

#
#
# start of backup
#
#

#copy mbr to file
echo „copying master boot record to /root/mbr.bin…“

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

len=${#EXCLUDES[*]} #Num elements in EXCLUDES

echo „Backup will exclude the following $len directories:“

i=0
while [ $i -lt $len ]; do
echo „$i: ${EXCLUDES[$i]}“
let i++
done

#prepend –exclude option to every directory
for EXCLUDE in ${EXCLUDES[@]}
do
EXCLUDE=“–exclude=“${EXCLUDE}
EXCLUDELIST=“$EXCLUDELIST $EXCLUDE“
done

#check if backup disk is available
if [ -d „$DIRECTORY“ ]; then
# Will enter here if $DIRECTORY exists

echo „Starting backup with tar cvpzf $DIRECTORY/${DATE}_backup.tgz $EXCLUDELIST /“
#start actual backup process
tar cvpzf $DIRECTORY/${DATE}_backup.tgz $EXCLUDELIST /

echo „change permissions of backup to root only access…“

chmod 700 $DIRECTORY/${DATE}_backup.tgz

echo „${DATE}_backup.tgz has been successfully created.“
echo „Size of backup is `ls -lh $DIRECTORY | grep ${DATE}_backup.tgz | awk ‚{print $5 }’`“

#deleting old versions
BACKUP_VERSIONS=(`ls $DIRECTORY | grep _backup.tgz`)

len=${#BACKUP_VERSIONS[*]}
i=0

#if more than 4 versions exist
if [ $len -gt 4 ]; then

#calculate number of versions to remove
rmno=$(($len-4))

#delete versions at the beginning of the list
while [ $i -lt $rmno ]; do

echo „removing ${BACKUP_VERSIONS[$i]} …“
rm $DIRECTORY/${BACKUP_VERSIONS[$i]}

let i++
done
fi
else
echo „cannot start backup, backup disk is not available“
exit 1
fi

If you want to restore the system you can do so simply by untaring to another disk:

tar xvpfz backup.tgz -C /path/to/disk_mount/

If you are restoring to another disk with a different partition scheme it may be necessary to recreate some entries in /etc/fstab as well as in grub.conf regarding the root device for grub and the kernel.
Restoring the master boot record is equally simple:

dd if=/root/mbr.bin of=/dev/target_disk count=1 bs=446

bs equals 446 if we do not want to overwrite the partition table that may be different on our new disk. If it’s the same we can also restore with bs=512.

HowTo use LVM to create filesystem snapshots for backups

If you have large amounts of data you’d like to backup, it can be cumbersome to use the normal backup tools such as tar. If data changes during the backup you might end up with an unusable backup.

If I want to backup my videos, recordings, music etc. of my MythTV box I cannot afford to take the filesystem offline for an entire night. Hence this solution.

I use XFS as my filesystem to store my stuff. It is a robust and modern filesystem designed for large files, precisely what I need for my recordings.

You need your volumes to be part of an LVM VG for this to work. You can find more information on LVM on IBM’s website: http://www.ibm.com/developerworks/linux/library/l-lvm/

The process to create a backup from a snapshot is quite easy:

# xfs_freeze -f /mountpoint/of/backup-fs

This will freeze the filesystem you want to backup essentially stalling all IO. For example if I have a LVM volume on /dev/myth/production mounted as /storage/mythtv I run

# xfs_freeze -f /storage/mythtv

Afterwards we can create a new logical volume with the same contents using LVM:

# lvcreate -l 500 -s -n snap /dev/myth/production

using the s argument tells LVM that I want a snapshot that is named „snap“ using the -n option.

Now I can safely mount the snapshot. I need the nouuid option because otherwise XFS would think it is mounting the same filesystem a twice. Basically that is the case though.

# mount -o nouuid,ro /dev/mapper/myth-snap /var/myth-snap

Now its time to unfreeze the „real“ filesystem and resume IO:

# xfs_freeze -u /storage/mythtv

At this point you can start the actual backup process using your favourite tool. Be it tar, rsync etc.

Once the backup run is complete you can safely unmount and destroy the snapshot.

# unmount /var/myth-snap

# lvremove -f /dev/myth/snap

The beauty of this is, that it can easily be put in a little script that runs every night. For a lot of applications it is also better to rely on a backup rather than a RAID which will only keep availability up but does in no way protect your data. Add a hotswap drive bay to your case and get a couple disk sleds and you have a fast, cheap and reliable backup solution up into multi terabyte territory…