Restoring backup-manager backups

For linux we have nice and easy backup software – backup-manager. Beside regular file backups it supports mysql dumps and svn dumps backups.

However, when you need to restore the backup you won’t find any command or script to do that. No wonder why – it’s so easy you don’t need them.

Steps to restore:

  1. If you were encrypting your backup images – use gpg to decrypt first.
  2. Use tar with appropriate command to uncompress main image.
  3. Repeat step 2 for every incremental image if you have them.

Sunday, February 10th, 2013

Disable menu bar in gnome-terminal

You can easily hide menu bar for gnome-terminal at a runtime. Obviously it’s rarely used and you can save some screen space by hiding it.

To hide it for newly opened terminal windows by default change this flag in gnome config:
/apps/gnome-terminal/profiles/Default/default_show_menubar to false.

gconftool --type boolean --set /apps/gnome-terminal/profiles/Default/default_show_menubar false

Sunday, October 18th, 2009

Setting up HP LaserJet P1005 on Debian Lenny

Do not confuse this printer with LaserJet 1005, it’s different printer (you’ll need drivers from foo2zjs package for 1005).

To make P1005 working you’ll need hplip package. Run hp-setup as root or run hplip from system menu. Unfortunately it is not able to download required plugin (at least in version 2.8.6b). You have to download it manually here and provide to hp setup tool.

Sunday, December 21st, 2008

tty’s killed on Ubuntu Hardy Heron VPS

If you’ve upgraded your Ubuntu VPS to 8.04 check your syslog. It could happen that getty processes are being killed all the time:

May  2 06:28:54 vps_server init: tty3 main process (19690) terminated with status 1
May  2 06:28:54 vps_server init: tty3 main process ended, respawning
May  2 06:28:59 vps_server init: tty6 main process (19753) terminated with status 1
May  2 06:28:59 vps_server init: tty6 main process ended, respawning
May  2 06:29:00 vps_server init: tty5 main process (19764) terminated with status 1
May  2 06:29:00 vps_server init: tty5 main process ended, respawning
May  2 06:29:00 vps_server init: tty1 main process (19772) terminated with status 1
May  2 06:29:00 vps_server init: tty1 main process ended, respawning
May  2 06:29:02 vps_server init: tty4 main process (19891) terminated with status 1
May  2 06:29:02 vps_server init: tty4 main process ended, respawning
May  2 06:29:02 vps_server init: tty2 main process (19892) terminated with status 1
May  2 06:29:02 vps_server init: tty2 main process ended, respawning

To get rid of this (you don’t need terminals on remote machine) edit files /etc/event.d/tty1, /etc/event.d/tty2, etc and comment lines that causes respawning:

exec /sbin/getty 38400 tty1

Friday, May 9th, 2008

Connecting Debian to GPRS via Sony Ericsson

I was connecting mobile through USB cable. A month ago I was trying to connect Siemens mobile through IRDA dongle, but I give it up and made a gateway on Windows machine.

This time I found a solution. kppp didn’t work anyway, but it’s not a problem.

Install wvdial, it will scan your computer for available modems during installation. If you forgot to plug your phone, you can rerun scanning with wvdialconf.

The only thing that I had to modify in generated config was additional initialization string:

Init2 = AT+CGDCONT=1, "IP",""

That’s it. Run wvdial and enjoy. Don’t forget to replace default route.

Tuesday, November 13th, 2007

Linux & Windows dual-boot – BIOS time problems

The problem is that by default these systems interprets hardware time in different way. Windows thinks that this is a local time, Linux – UTC (GMT). As a result you can have problems with jumping time each time you reboot into some OS. However you can force Linux to interpret hardware time as local, edit /etc/default/rcS and set UTC=no.
If you are running these two shits (Win & Linux) on a laptop you may have additional problems, Linux may still show wrong time. If you look into logs, you’ll find that probably it can’t open /dev/rtc device. In this case edit files /etc/init.d/ and and set parameter HWCLOCKPARS=--directisa

Thursday, October 4th, 2007

Change charset for all tables.

A lot of linux distributions comes with mysql with default charset latin1. In modern world it seems to be rudimentary, for i18n utf8 is a must. So converting existing mysql databases/tables to utf8 is not an uncommon task. There’s no problem with it, mysql has ALTER TABLE SET CHARSET statement. But what if you have several dozens of tables? And what if each table has a lot of text fields? You’ll spend a lot of time in front of mysql console or phpmyadmin. Or you’ll have to generate script from table/field names.
I offer simple solution when all your data is english (I can’t predict behaviour if you have other data).

  1. Make mysqldump of your entire database
  2. Change all charset definitions sed -i 's/latin1/utf8/' dumpfile.sql
  3. Load dump back to database

Monday, September 24th, 2007

Recursive ftp upload/download

Today we have to upload the whole directory tree to our site. How we can do it? If you use regular ftp command, this task becomes tedious and exhaustive job. You have to recreate each directory, change to each directory locally and remotely and perform mput or mget. If you have complex directory structure it is almost impossible to do that without a mistake. Solution? – Use lftp instead. It has mirror feature which allows to copy entire directory tree. To upload, use -R switch.

Wednesday, September 12th, 2007

Copying changed files since some revision under Subversion

I continue my previous post about getting changed files with subversion. I needed to get all changed and committed files since some revision till HEAD revision and upload them to production server. I don’t want to copy all working copy nor exporting entire repository on server. Just changed files. First solution will be filtering files by modification date. But what if you have a lot of other unversioned files in your working copy, which are changed frequently?

So the solution is to look at svn log and get affected files for each revision we are interested in. But this is boring. Use this command instead:

svn log -vq -r 104:HEAD | grep '^   [AM]' | cut -b 6- | sed 's/ (from .*:[0-9]*)$//' | sed 's|^/path/prefix/in/repository/||' | sort -u | xargs -I '{}' cp --parents {} /temporary/destination/dir

Note, there should be three spaces before [AM] in grep regex.

It will do the same. First, get log with list of changed files and without your comments for revision from 104 to HEAD (as an example). Then get only modified and added files, we don’t need deleted. After that remove first column with status indication, remove with sed “(from …:103)” svn note, if we have moved or copied resource. I used sed once more to make remote path relative to my working copy, so I can use cp command on list of files. sort -u is required to get unique list, as some files could be changed in several revisions

Saturday, August 11th, 2007

Copying only modified files under SVN

If you are web developer and you are working with Subversion, then you probably did this thousand of times. You have modified some files (probably a lot of them), and after that you have to update your dev/prod server. It can be pain in the ass, if you have large repository with complex directory structure.

The best solution will be to have working copy on dev/prod server and use svn checkout or svn export. But sometimes it won’t work, e.g. if your repository is not accessible from your server, or you don’t want to commit your files without testing them on server or whatever else.

If you are working under *nix, here’s useful command that will facilitate this tedious task:

svn status | grep '^[ADMR]' | cut -b 8- | xargs -I '{}' cp --parents {} /temporary/destination/dir

Let’s see what it means. First, we take status of each file/directory in the working copy, then filter only modified/added/deleted/replaced files (it’s /^[ADMR]/ regex for the first column in svn status result). Then remove column with files statuses and pass it to copy command preserving directory structure. That’s it.

Sunday, August 5th, 2007