Backup database

Written on 11 May 2007 by

This time, the most usefull command line is ussually working with server, is how to backup database server, especially mysql server. Just dump the entire database, compress and move to another media. Working with root user:

Dump mysql database into file with complete insert and drop table:
# mysqldump --opt --allow-keywords -Q -c -u username -p \
dbname > filename.sql

If you want dump all table just chage ‘dbname’ with ‘–all-databases’. Later, use bzip2 or gzip to compress that large sql dump:
# bzip2 filename.sql
After that move bzip2 file to safe place (backup media). To restore that backup, first you must unzip it and use flat sql file with mysql command:
# bunzip2 filename.sql.bz2
# mysql -u username -p dbname < filename.sql

That’s it, simple and fast enough ;-) Want to know what the meaning all mysqldump option that I use? Just type ‘man mysqldump’ and read it ;-)


who’s opening this file?

Written on 9 May 2007 by

When working with multiple tab opened at our terminal and su there su this, we can get lost where pwd our regular user is. This is make a trouble when we try to umount some device.
# umount /media/disk1
umount: /media/disk1: device is busy
umount: /media/disk1: device is busy

What the hell!! who or where is that use that device? Yes, there is a little application that can do a tracking who use the device, that app called lsof..
# lsof | grep /media/disk1
bash 2564 user1 cwd DIR 0,27 4096 2 /media/disk1
su 2778 root cwd DIR 0,27 4096 2 /media/disk1

From the pid we get, we can track where terminal tab is open that device ;-)


RPM just freeze

Written on 8 May 2007 by

Sometimes rpm just freeze, no action, no process. You can experinace with this when you manage package directly with rpm or via yum. I don’t know if this is a reported bug or not, but I know to deal with this. This trick I know long enough to forget the sources ;-)

This is the command line:
# killall -9 rpm
or
# killall -9 rpmq
# rm -f /var/lib/rpm/__db.00*