Home » Posts tagged "Ubuntu"

Using rsnapshot for daily PostgreSQL backups

Having done backups for MySQL using rsnapshot before I recently had to do the same thing for PostgreSQL. Turns out PostgreSQL has similar tools to do this and it’s actually quite easy to set it up.

First, assuming rsnapshot will run under the root user you’ll need to create a .pgpass file at /root/.pgpass that will hold the credentials that are required for setting up a connection with your database. The expected format is host:port:database:user:password, so for example:

localhost:*:mydbname:myusername:mypassword

With that in place create a shell script that will use this file and run the pg_dump program. Put it some place you can remember, e.g. /usr/local/bin/postgresql-backup.sh:

#!/bin/bash
export PGPASS=/root/.pgpass
pg_dump -w -h localhost -U myusername mydbname > postgresql-dump.sql
gzip postgresql-dump.sql

Again, just as with the using rsnapshot for daily MySQL backups article you need to configure rsnapshot.

Next is setting up /etc/rsnapshot.conf which is easy as well. At the end of this file you’ll find all the instructions of which directories to backup. Enter the next line. Do note that rsnapshot.conf uses a tab to separate values.

backup_script   /usr/local/bin/postgresql-backup.sh  postgresql/

To enable daily backups uncomment the next line:

#interval       hourly  6
interval        daily   7
#interval       weekly  4
#interval       monthly 3

To make rsnapshot run every day update /etc/cron.d/rsnapshot:

# 0 */4         * * *           root    /usr/bin/rsnapshot hourly
  30 3          * * *           root    /usr/bin/rsnapshot daily
# 0  3          * * 1           root    /usr/bin/rsnapshot weekly
# 30 2          1 * *           root    /usr/bin/rsnapshot monthly

Finally, try running rsnapshot. After it has run check your backup directory, which on Ubuntu 12.04 defaults to /.snapshots/. Be sure to mount /.snapshots/ on a separate drive. Because what use is it if your data drive contains your backup and decides to commit suicide?

$ sudo rsnapshot daily

Your PostgreSQL backup file should now be located at /.snapshots/daily.0/postgresql/postgresql-dump.sql. You can restore this file with the psql commandline utility.

Favorite programming font on Windows: Consolas 10pt bold

For years I’ve used Courier New in my programming editors and terminal (PuTTY). But there’s a much better font available for that kind of stuff. For the last couple of years I’ve been using Consolas, which is shipped with Windows. I’ve configured my editors and PuTTY to use Consolas 10pt bold as I find it by far the best readable font to use for programming. This font is just the right size at 10pt and setting it to bold gives it a very smooth look.

Here’s how Consolas 10pt bold looks in GVim on Windows 8:

consolas

Recently I’ve given some other fonts a try as well because in the showed examples it appears they make a nice programming font. Not too long ago the Adobe Source Code Pro font was released and looking at the screenshot at that page it looks really nice. So I decided to download and install it. But trying it in GVim didn’t gave a satisfying result. It doesn’t look too bad, but it isn’t as compact as Consolas is:

source code pro

When using Linux (Ubuntu) I always use Droid Sans Mono. But for some reason it looks really bad on Windows:

droid sans mono

As you can see Droid Sans Mono is even bigger and just doesn’t look right. I wonder why this is though I suspect it has to do with the font rendering on Windows. I’ve found font rendering on Linux a lot better and for what I’ve seen on Mac OSX as well, though I’ve recently heard a Mac user saying he found the font rendering on Linux even better.

And OK, the fonts don’t look that bad but imagine having to look at it all day when programming. All these examples have been set at 10pt bold and the extra space taken by both Adobe Source Code Pro and Droid Sans Mono is just bad in my opinion.

So far I haven’t found anything better than Consolas when it comes to a programming font on Windows. I’m not looking for a replacement of it but I’m always willing to try something new or different. My main disappointment I think comes with how bad Windows renders these fonts, because I know Droid Sans Mono looks good on Linux. If there’s any programming font that renders really well on Windows I’d really like to hear about it.

Getting ProFTPD to work on Ubuntu 12.04

For what I can remember it has always been possible (at least) since Ubuntu 7.04 to simply do a sudo apt-get install proftpd to get a working FTP server running. It seems that starting with Ubuntu 12.04 no more!

After installing proftpd on 12.04 (the package is now called proftpd-basic) you’ll be unable to start the service. I’ve tried it both as standalone and using inetd but neither would work. ProFTPD, or rather its init.d script will report ProFTPD warning: cannot start neither in standalone nor in inetd/xinetd mode. Check your configuration. Yes, that helps a lot.

Looking at the syslog I found the following message when trying to connect to the FTP server: error: cannot execute /usr/sbin/in.ftpd: No such file or directory. It turns out that this path is defined in /etc/inetd.conf and for Ubuntu 12.04 it appears that the proftpd-basic package doesn’t install these. If you don’t have the FTP service defined in inetd/xinetd it simply rejects any connection, giving less helpful error messages.

So the fix to this problem is rather easy. If the file doesn’t exist yet create /etc/inetd.conf (regardless if you use inetd or xinetd). Then, simply add the following line, or replace the existing one with the following:

ftp     stream  tcp     nowait  root    /usr/sbin/tcpd  /usr/sbin/proftpd

Now restart the service: sudo service inetd restart or sudo service xinetd restart.

So the only change you really need to make is change the path to the FTP server. This fix works for both inetd and xinetd. For a proper solution for xinetd please see the section below.

Proper xinetd fix

I reckon that the creators of xinetd decided to support inetd compatibility by supporting the /etc/inetd.conf file. If you want to configure xinetd the proper way you can create a config file for it in /etc/xinetd.d/ftp and stick the following lines in it:

service ftp
{
      disable = no
      flags                   = REUSE
      socket_type             = stream
      wait                    = no
      user                    = root
      server                  = /usr/sbin/proftpd
      server_args             = -c /etc/proftpd/proftpd.conf
}
  • socket_type: Sets the network socket type to stream.
  • protocol: Sets the protocol type to TCP
  • wait: You can set the value to yes or no only. It Defines whether the service is single-threaded (if set to yes) or multi-threaded (if set to no).
  • user: User who will run proftpd

And finally restart the service: sudo service xinetd restart.

(Source for setting up a service for xinetd).

Why more people aren’t using Ubuntu

If you’ve ever wondered why you’re the only Ubuntu user in your office, or in your group of friends, then you’re not alone. The free, powerful operating system, built on the Linux framework, is not only available to everyone for the sum total of zero anything, but is also adaptable, fast, and capable of satisfying even the most demanding user.

However, there are a number of issues which may put people off, or are why they simply don’t even know about Linux, let alone Ubuntu.

1) Market visibility

The problem with open source is that not only are you not Microsoft, and therefore the default operating system for almost every pre-built computer in the world whether the user is a handset engineer for o2 or a novelist, but you’re also not able to put out advertising or push Ubuntu into people’s awareness.

2) Linux’s “complex” reputation

Linux is known for being the least simple and straight-forward operating system out of Windows, Mac OSX and itself. Whether or not this is actually true is highly debatable. However, its reputation isn’t being changed by the legions who use it, and as it is rarely introduced into office environments for use by staff who aren’t working in the IT department, it seems like it could do with a bit of a jumpstart in the “it’s actually quite easy” department, given that it is no more complex than any other OS.

3) Accessibility

PC companies, I’m sure, would love nothing more than to lose money by offering Linux installs instead of Windows. Sarcasm aside, Ubuntu is something you’d search for, but not something you’d be presented with. The tech press needs to do a better job of opening people’s eyes to the potential of open source platforms, and users helping out can never be a bad thing either. After all, it’s free, easier on your hardware, and extremely capable, scaling with your IT skill level. What’s not to like?

My new PC

After almost 5 years of usage I decided it was time to replace my trustworthy desktop PC, a HP Pavilion Elite m9060.nl. The PC really started to show its age. It was becoming a bit too slow for today’s software applications, at least to my liking. The limitation of 4GB of RAM set by the motherboard also didn’t help much. Recently I upgraded my 3.5 years old HP Pavilion dv7-1210ed laptop with a SSD and upgraded the RAM from 3GB to 6GB and really found out that for me 4GB is the absolute minimum and with 6GB you get to have some breathing space. I was also sold by the SSD. Boy do those give you one hell of a speed increment!

Since I already had maxed out my RAM and the processor (a Core2Duo E4500) wasn’t quite cutting it I decided to replace it. Sure, I could’ve added a SSD in it and probably extend it’s lifetime with another 6 months or perhaps a year. But that would only postpone the inevitable.

At first I had planned on getting a pre-configured PC by either Dell or Medion. They both had pretty nice offers, especially Medion. The alternative was to build one myself. In the past I’ve been, or actually my brother, rather unfortunate with these kind of PC’s. There was always some hardware issue. Considering that was over 10 years ago and with some old friends convincing me to put together my own PC I decided to take a look if that would give me more bang for the buck.

It turned out it did. The Medion PC I had in mind was around € 1049,-. It contained a nice 2TB HDD and a 64GB SSD (too small for my liking) and the latest Intel i7-3770 as well as a budget NVIDIA GPU and 16GB RAM. With these specs in mind I started configuring my new PC. In the end I came up with this:

At first I had selected a 128GB SSD and the NVIDIA GeForce GTX 570 video card but it increased the price quite a bit. Since I’m not a PC gamer it would be a bit of a waste of money to get this video card. Instead decided to take my older NVIDIA 9800GT Green Edition from my HP PC, which originally had a low end NVIDIA 8400GS GPU in it.

In the end I got all this for around € 921,- saving me € 128,- euro on the Medion PC and still get a bigger SSD.

I only had to put it together, for which I asked an old classmate to help me with. The main reason I asked help was because I was a bit spooked about putting the CPU in its socket. The CPU was the most expensive part of the setup and I was afraid of bending any CPU pins… Did I look like a fool when the CPU was being placed! The buggers no longer have those long pins that the old CPU’s have. It’s been too long for me since I worked with this kind of stuff.

I’m very happy I did decide to build my own PC. I’ve gotten better value for the money and boy oh boy is this machine fast! Windows 7 boots incredibly fast and software applications mostly start instantly. Even stuff like Visual Studio and Adobe CS. I also did gave Ubuntu 12.04 a little test run just to see how fast it was: it boots in about 3 seconds.

Conclusion: I’ve got a kick-ass PC!