Friday, November 27, 2009

Time Machine on Linux with LVM

Mac's Time Machine is a good thing. You can accomplish that behavior on windows with shadow copy (as far as I've heard), about what about Linux?

You can do it with LVM volumes with a small bash magic!:)

I do this way from cron or by hand if I need an instant snapshot.

#!/bin/bash

VG=vg1
LV=root
MOUNTPOINT=/lvm-backup
KEEP=4
SIZE=100M

DATE=$(date +%F-%H-%M-%S)

sync
lvcreate --size $SIZE --snapshot --name $LV-$DATE /dev/$VG/$LV
mkdir -p $MOUNTPOINT/$LV-$DATE
mount /dev/$VG/$LV-$DATE $MOUNTPOINT/$LV-$DATE

sync
COUNT=$(lvdisplay $VG\/$LV|grep -v Name|grep $VG\/$LV|wc -l)
while [ $COUNT -gt $KEEP ]
do
TOREMOVE=$(lvdisplay $VG\/$LV|grep -v Name|grep $VG\/$LV|sort|head -n 1|cut -d'/' -f4|cut -d' ' -f1)
umount $MOUNTPOINT/$TOREMOVE
rmdir $MOUNTPOINT/$TOREMOVE
lvremove -f $VG/$TOREMOVE
sync
COUNT=$(lvdisplay $VG\/$LV|grep -v Name|grep $VG\/$LV|wc -l)
done

Wednesday, November 25, 2009

Proxy for apt-get

To access apt through proxy, edit the file /etc/apt/apt.conf.d/70debconf and add the line

Acquire::http::Proxy "http://proxy:3128";


where proxy:3128 is your proxy server address and port.

Tuesday, November 24, 2009

How to make a graphical input popup from shell scripts?

I use this method from a small script what asks for a samba password, and then mounts that share.

!/bin/bash
P=`zenity --entry --hide-text --text="Foo" --title="Bar"`
echo $PASS


You can use your $P for anything you want.

Saturday, November 21, 2009

Filesystems

I was in a Sun training a few weeks ago and ZFS is stunned me. It's flexibility and the fact that is combines the file-system, the software raid and the logical volume management. I was so envy on Solaris users. I looked around something similar on Linux, unfortunately I found only one approach: btrfs, what is so work in progress... [sigh] when will we have such a great file-system?

Saturday, November 14, 2009

LionWiki: the minimalist Wiki engine

LionWiki is a minimalist file based, php Wiki engine. It requires just one file to function. I use it for my personal wiki and TODO list. It is actively maintained, and a nice little easily customizable wiki.

Friday, November 13, 2009

Zen To Done: The Simple Productivity E-Book!

I own a copy of the e-book: Zen To Done, what I recommend to everyone.

It is a book about how to organize your life. It teaches you several habits what makes you more productive so your life easier.

To mention two things, I adopted the TODO list and I have a notebook what I carry always with me to write down everything comes to my mind. I use paperblanks' Romantic Sensibility because it looks great!:)

I recommend Zen To Done to anyone who wants a more organized and simpler life.

Saturday, November 7, 2009

How to build custom deb packages?

If the deb package already exists, any you only want to rebuild it, after applying a patch, or I don't know why, then you have to do the following.

apt-get source packagename

... this is when you modify the sources ...

dpkg-buildpackage -rfakeroot -uc -b
dpkg -i yourdebfile.deb

That's all!:)

If your distro doesn't consist the package you want to debize, then check out checkinstall.

Sunday, November 1, 2009

dvdisaster the ultimate tool for optical disc rescue

Do you have scratched dvds? Do you have a big disk library, what you want to somehow secure, but you don't have enough space to image them all? Then dvdisaster is the tool for you.

It can read scratched disk till it gains every piece off from it, and if you made error correction data (14.3-33.5% of the original size) from your dvd before it damaged (preferably right after buying it) it can read back more damaged data.