Simple Rsnapshot Setup

Rsnapshot is a perl-based backup script manager. It is a journalised backup system – meaning that it copies all your files across to the backup media once – and then the only data it transfers after that is the changes. The backups appear on disk as complete copies – but where two generations are exactly the same file, they’re actually symlinked to the same data.

Backup Strategies

Rnsapshot has hooks for scripts that run before and after the actual snapshotting. I use the “before” script to:

The after script just unmounts the drive. To add these extra scripts you just uncomment the lines containing the cmd_preexec and cmd_postexec paths and point them to your scripts.

Getting Started

Well I could write a lot about this but to be honest I doubt I’d do better than the excellent rsnapshot howto so I suggest you read that for how to do it. Basically, enter the path you’d like to back up to, the interval you’d like to use, and then a bit further down the page which directories you want backing up (the default is /home, /etc and /usr/local) – then run the command! The howto even includes instructionsn on setting up cron to call the command regularly.

Rsnapshot Conclusion

Rsnapshot was a good tool to stumble upon as a learner sysadmin (which I am) and its very easy to use. I love the fact that it isn’t rocket science, but its a really nice, usable version of a collection of scripts which are duplicated by system administrators the world over. The file structure of the backups is the same as the content that is backed up and retrieving any generation is as simple as copying a file over. I’m sure there are other solutions out there, but I’m a convert and use it on all the local servers I administer (Ubuntu boxes, it works a treat).

Top top Tips

That is to say, some top tips for the command-line program top. Top is a program to show you the top processes consuming resources on the system. You can then press other keys and the program will respond. For example:

q to quit

z to get a colour output

x to highlight which field the results are sorted by

< and > to change which field it is sorted by

c to tooggle between the program name and the full command that was run

I don’t use every program often enough to just remember the keyboard shortcuts so its nice to keep a virtual crib sheet :)

Reliably Avoid Subversion Collision – Commit First!

Subversion is a source control system – an excellent accompaniment to software development especially in a team setting. When working with a number of people, it is likely that at one time or another there will be collisions – for example at the moment a project I am working on has a team making some amendments requested by the client for a website. Subversion is handling it all well but the main template files and stylesheets are colliding often as everyone is making changes.

Commit First!

The collision will only occur if you check in a change and someone else has already changed that line in a file. To avoid getting a collision in your working copy, the best thing to do is to commit your change before the other person does.

This approach of commit early, commit often will help you to develop more smoothly without the interruptions of a collision and without struggling with lots and lots of merged files when you’ve left it too long between commits. Additionally you’ll have more checkpoints in your own development history so if you need to go back a few steps, the repository will be able to help you whereas if you didn’t check in, it won’t!

That’s my tip for the day – on a day in a place where many people are bug fixing a single project!

Setting up MySQL to listen to external ports

I had some difficulty setting up mysql to listen to external ports on a server – the development web server uses databases on another box. The important setting was in /etc/mysql/my.cnf where I removed the line:


bind-address = 127.0.0.1

You should then be able to connect a client from another server to this mysql server.

As a warning – bear in mind that it is usually good practice to set up user permissions to only be valid when accessing from localhost if that is the intention – check your mysql table if you can log into the server but then start getting permission problems for other users.

Hope this helps someone!

Twitter, meet Facebook. Facebook, Twitter

Having recently embraced the social networking revolution, or not, I have recently been getting exasperated by how out-of-date my status gets when I can’t be bothered to update it. And how annoying that there are statuses on both Facebook and Twitter which are both out of date.

I stumbled across the instructions at http://www.jeffsandquist.com/HowToPublishYourFacebookStatusToTwitter.aspx and used these so that when I update facebook, the same status appears as a tweet1 on twitter!

If you use both applications then I’d recommend giving this a try. It uses twitterfeed as a go-between to get your RSS feed of statuses out of Facebook and in to Twitter. If you give it a try, let me know how you get on?

1 I am assured that “a tweet” is the singlar label for an entry on twitter. And furthermore that a person posting these entries can be said to be “tweeting”. So now you know!

Women Together

Most people know that I’m active in the phpwomen community, women in technology is something that I really believe in but won’t start ranting about right now (or I’ll not get round to what I was going to say!).

Today I’m getting to grips with irssi which is a command-line IRC client. I was struggling with some quite dry documentation when I came across this tutorial from Ubuntu Women which has really helped me to get sorted out.

Yay for the women :)

Wiki Wonder

I love wikis for workplace documentation. For anyone who doesn’t know, a wiki is a web page with an “edit” button, so you can change the content of it if you have something to add or something is out of date or missing. Wikipedia is the obvious example.

So why is it, whenever I set up a wiki, I spend the next six months fielding requests from people for me to add things to it for them?

Textpattern To Serendipity

I’m planning on migrating this site to a new platform soon, I’ve been looking around for an alternative to textpattern. Textpattern has been great but I’ve kind of outgrown it. Its easy to use but a bit “fluffy” and it eats my code excerpts which is really annoying.

I’ve picked serendipity as my intended target, its very modular and uses smarty for templating which I like and am familiar with. And if its good enough for sara and davey then I expect I will get along with it just fine.

Meeting Serendipity

So I installed Serendipity, nice easy installer, and started to look in the admin panel. There was a button for “Import Data” … you say what kind of blog platform you are coming from, and enter your database credentials and it attempts to import your old data. So I kind of tapped in my details.

Literally five seconds later I was looking at a blog with my entire history in it. Its got comments, posts, categories and users. I’m blown away, its utterly fantastic.

Finishing touches

The import didn’t cover stuff like images, which will need a whole series of conversions and text replacement on the posts to get sorted, and it seems to have chewed on some HTML entities. Also textpattern uses a post body with an optional excerpt and serendipity uses post body with optional extended body which has done some weird things to the import. It doesn’t help that I did use excerpts for a while in textpattern and then stopped after complaints from people reading on feed readers.

I’m also procrastinating over a theme for the new site … obviously it will involve a very empty stylesheet and at least two shades of pink but I’m not quite there with it yet. Once I’ve converted my content then I’ll just stop fiddling and use what I’ve got I think. I’ll also post the conversion scripts once I’ve finished with them.

Finally I will have to put together a bunch of HTTP 301’s since serendipity won’t support having article titles as the only thing after the domain name on the URL. I’ll keep you posted :)

grep: unknown directories method

The title of the post is the error message I got when attempting to grep a directory containing a file whose name started with a hyphen ( – ).

What has happened is that grep interprets hypens as switches, as if the idea was to convey options to use. This gave me a problem as I realised the file shouldn’t have been placed there in the first place and subversion was unable to remove it.

The Double-Hyphen Trick

The resolution is to pass two hyphens to the command, I didn’t know this before but this means “enough of the options, here’s the list to operate on”, or words to that effect. I used them to remove the file in question


svn rm -- \-*

Hopefully I’ll remember to look here next time I see this error message … but maybe not. So long as I don’t find myself on Google again

Cleaning up Windows Line Endings in Vim

I have a file which has been edited in windows with an incorrect setting. All the lines have


^M

At the end of each line.

To search for these in Vim, you can type ctrl+v (to mean “take my next key combination literally”) then ctrl+m. To clean up my file I used:


:% s/^M$//

Where the ^M is typed using Ctrl+V, Ctrl+M. I’ve recorded it as a macro as I seem to be fixing the same thing a lot these days. Hope that helps someone!