Bytemark backup script
As some people are aware, I use Bytemark for all of my hosting, and I also resell some of their services. I’ve recently switched to performing my backups via rsync and thought I would share the simple script I use in case any other Bytemark customer is looking to do the same thing.
#!/bin/bash
BACKUPDIRS="/etc /home"
VMNAME=""
for dir in $BACKUPDIRS ; do
rsync --delete -qazr "$dir" $VMNAME.backup.bytemark.co.uk::$VMNAME/"$dir"
done
The only change required is that you need to set the VMNAME variable to the name of your virtual machine, and change BACKUPDIRS to list all the directories which you want to backup.
Some important caveats:
- You must have Bash installed in order for this script to work, though it doesn’t have to be your default shell.
- This script will not backup non-file data, such as MySQL databases. I will post a separate script once I get round to performing this task.
- The complete contents of the directories specified in
BACKUPDIRSwill be backed up, there is no way to say ‘backup/homebut not/home/paul‘. - The first time you run this script it will take a while for rsync to copy all the data, but subsequent runs should be much faster.
- I think this only works for virtual machines and not dedicated hosts.
As rsync only copies the files required, you can probably run this script more frequently than a full backup script.
posted by Paul at 9:00am on Monday 3rd May 2010 | Comments Off
Thoughts on tax reform
In the run up to the general election, one thing which has disappointed me is that none of the three main parties have used the economic crisis as an opportunity to suggest radical reform of the tax system in the UK. Sure, the Lib Dems want to increase the personal allowance and introduce a mansion tax, but that’s really just fiddling around the edges.
My slightly more radical proposal would be to scrap national insurance and increase income tax and corporation tax to compensate, which would bring the following benefits:
- The National Insurance Contributions Office could be closed, with the staff being redeployed to deal with other issues, such as manning the understaffed HMRC help lines or cracking down on tax evasion.
- One less tax to deal with for companies and individuals should reduce administration costs (payroll can be a serious pain for small businesses).
- Removing NI and increasing tax on all income would stop people from trying to avoid tax by putting a limited company between themselves and their clients and taking profits as dividends (which aren’t subject to NI).
- Generally speaking, the simpler you make a system, the less likely it is to make mistakes.
The other reform would be to use the scrapping of NI as an opportunity to simplify the pensions system, by giving everyone the basic state pension, instead of having all these complicated rules about how you earn ‘qualifying years’ and how many you actually need. I can’t help thinking that the current system costs more to administer than any benefit we derive by not paying everyone the full basic state pension.
How much would income tax have to go up by to compensate for the removal of NI? I’m not sure, but it would be less than the rate of national insurance because NI is only levied on earnings—i.e. wages from employment and self-employment profits. As a result, the Treasury would see an increase in tax receipts on sources of income which are not currently subject to NI, such as dividends, which would partly offset the necessary rise in tax on earnings.
How can this be sold to the public? One simple way is that anyone who is employed or self-employed will pay less tax in most cases, as their new rate of income tax will be lower than the existing income tax + NI levels on their earnings. Pensioners would presumably like the fact that they don’t have to have a degree in government administration to work out how much pension they’re entitled to. Small businesses will love the removal of the ‘tax on jobs’ and ‘administrative nightmare’ that is employer’s NI contributions.
Who will lose out? Well, a few consultants who currently use a company to avoid NI might complain, but that’s their fault for avoiding tax in the first place. Pensioners might pay a bit more tax, as they don’t currently pay NI, but that can be rectified by giving them a higher personal allowance and rich pensioners will just have to feel the pinch.
Now, the only question remaining is how do I set up a meeting with Darling, Osborne and Cable to convince them to take my genius idea on board, or at least appoint me as their Chief Tax Reform Adviser?
posted by Paul at 11:06am on Saturday 1st May 2010 | Comments Off
django user variables and login forms
I’ve been working on Pub Gateway this afternoon, and I ended up with a slight problem with django’s authentication module. I’d managed to build a working login form which sent the user back to the home page if they entered a valid username and password. The only other thing I wanted was to change the base template to display a link to the login page for users who hadn’t logged in, and a link to the logout page for users who were logged in. I was using the following template code to decide which link to display:
{% if user.is_authenticated %}
<a href="/accounts/logout/">Logout</a>
{% else %}
<a href="/accounts/login/">Login</a>
{% endif %}
However, the template was only showing the logout link if I was on the login page—on all the other pages it was showing ‘login’ instead, even if I’d already logged in. It turns out that the user variable isn’t passed to the template unless you supply what django calls a ‘context processor’, which is added by default to the login view but not on views which I’d created myself. After a bit of searching through the documentation, I had to modify my views like so:
Original view:
return render_to_response('core/about/index.html')
New view:
return render_to_response('core/about/index.html', context_instance=RequestContext(request))
Possibly obvious to anyone who knows django already, but it took me about half an hour of reading through the documentation to figure this out. It seems a bit clumsy to have to do this on every view, and I’m surprised that there’s no obvious way to say ‘do this on every view unless I tell you not to’, but at least everything is working now.
posted by Paul at 6:25pm on Saturday 24th April 2010 | Comments Off
A pint with the party leader
Everyone has been talking for the last week about how well Clegg did in the recent leaders debate on ITV. The polls have him on anything up to a 14 point lead on Cameron and Brown, and everyone seems to be joining the 101 Facebook groups and buying the t-shirts. Yes, you too can be the proud owner of an ‘I agree with Nick’ or ‘I voted Lib Dem before it was cool’ t-shirt, though I’m tempted to buy a ‘Dave the Chameleon’ one instead.
Why is this? Well, Clegg is probably the first leader of the Lib Dems who people can look at and think ‘yes, I can see him as Prime Minister’. Paddy Ashdown was too early, when the Lib Dems had absolutely no chance of getting elected, and Charles Kennedy was a jolly nice chap but didn’t really have that statesman feel. You don’t see Nick Clegg appearing on Have I Got News for You either, which is just as well because I don’t think he’d be able to shrug off the jokes about the Lib Dems not being a serious party.
The only thing is, I don’t particularly like or dislike Nick Clegg, whereas I did (and still do) like Charles Kennedy. I’d go for a pint with Kennedy, but not with Clegg, Cameron or Brown. If you believe their characitures in the press, Brown would glass someone, Cameron would have a dry white wine poured for him by a butler (although he’s on record as being a fan of real ale) and Clegg would sit at the bar for hours trying to decide what to drink, or whether to even have a drink at all…
posted by Paul at 8:21pm on Wednesday 21st April 2010 | 3 Comments »
Register to vote
Have you registered to vote? There’s still time, it’s a really simple process, and it gives you the power to help decide who will represent your area in Westminster for the next five years. You may also have local elections, depending on your area.
Alas, I haven’t got round to forming the Currybeer Party in time for this election—perhaps next year. ![]()
posted by Paul at 5:30pm on Tuesday 13th April 2010 | Comments Off
Thoughts on frameworks
I’ve been building dynamic web sites for over ten years now, and one of the things which has bugged me enormously is the huge amount of repetitive code I have to write, especially for form handling (including validation) and access control. At least half of my coding time is spent on this sort of work, and the lack of creativity involved leads to boredom, which inevitably leads to dissatisfaction with the work and mistakes. Apparently though, there is this silver bullet called a framework, which will solve this problem for me…
I heard about frameworks a few years ago, when the various web development groups were getting all excited over the memory-eating monstrosity which is Ruby on Rails, under the reasoning of ‘37signals use it, so it must be the best thing since sliced bread!’ I went as far as reviewing a book which was aimed at PHP programmers who wanted to get to grips with Rails, but I wasn’t convinced that it was any good. The initial investment, in terms of the amount of time required to learn the framework and the Model View Controller way of doing things, was also too much of a hurdle. Sure, I might save some time in the long run, but there was no guarantee that this would warrant spending an undefined amount of time getting to grips with the framework’s particular way of doing things.
However, I’ve been playing around with Django this weekend, and I must admit that it has impressed me (this is not a simple achievement, for I am terribly fussy about anything to do with programming, whether it’s a library, framework, IDE or coding style). Like any framework, it has the ability to turn models into database structures and forms, a built-in admin interface and scaffolding which you can gradually replace with your own templates. Its major selling point though is that it is incredibly easy to pick up. I put this down to two reasons:
- It has good documentation, including a self-contained tutorial.
- It has good documentation, including a self-contained tutorial.
I realise that’s actually just one reason, but it’s so important I feel it’s worth stating twice. As a result of the documentation, someone who has never programmed in Python (apart from a one day tutorial more than a year ago) has been able to create a clone of a site written in PHP in about half the time. As a result, I’ll be using Django to rebuild Pub Gateway over the coming weeks, and then moving on to kick start Rogue Students, which I’ve neglected for some time.
posted by Paul at 5:21pm on Sunday 11th April 2010 | Comments Off
Announcing… Pub Gateway!
Pub Gateway is now available for your viewing pleasure.
A few things to note:
- The design is simple, because I’m not an artist and can’t create amazing logos. I’ll probably pay someone to come up with a decent design and logo at a later date.
- There are only a few pubs available as I haven’t written the interface to submit them.
- There are no photos of pubs because I need to buy myself a new digital camera.
- The ‘nearby information’ feature (e.g. ‘railway stations with X miles of the pub) isn’t ready yet – mainly because I found that the metadata I need is not marked up properly on Wikipedia. It will probably take me a few weekends to fix all the 483 pages so that the useful information can be extracted.
However, the main structure of the site is in place (mod_rewrite rules, user authentication, templates to display basic details about a pub etc.) so it’s now a case of gradually building up all the features necessary to make a complete site.
posted by Paul at 1:00am on Tuesday 6th April 2010 | 2 Comments »
Thought for the day
Thought for the day (which probably wouldn’t get onto Radio 4):
- Any sane mail server logs the IP address of any remote server which connects to it and attempts to deliver spam.
- It’s possible to map an IP address to a physical location, with a reasonable degree of accuracy (if you pay for a good database).
- Long range missiles can be launched by computer and targeted to a precise location (unless the targeting system has been programmed by someone who gets latitude and longitude mixed up, or the missiles are American).
Combine these three facts together and you have a simple (albeit rather extreme) method of dealing with spammers.
posted by Paul at 5:05pm on Wednesday 31st March 2010 | Comments Off
UKUUG Spring conference
Three days of this week were taken up by the UKUUG Spring 2010 conference, which I seemed to volunteer to lead the organisation on once again (and for next year as well by the looks of it!). I’ve still not fully recovered, probably as a result of going down with a cold the morning after the last day of the conference, but have nearly finished emailing all the speakers and sponsors to say thank you, and uploading the slides to the conference wiki.
Tuesday involved a tutorial on the SCons build system, by Russel Winder. I struggled a bit with some of the exercises as I’m not a Python programmer (it’s on my ‘things to learn’ list), but I was sufficiently convinced to use SCons for any new projects where I need a build system, as it’s vastly superior in terms of usability to both make and ant. Russel is also an excellent tutor who gets the blend of teaching and humour spot on, which made the day an enjoyable experience.
Wednesday and Thursday were the main conference days, with talks ranging from FreeBSD’s virtual network stacks to a live demo of setting up Ubuntu Enterprise Cloud in 30 minutes (I’m still amazed that nothing went wrong with the multi-projector and network setup!). There were also some lightning talks which involved a brave but ultimately unsuccessful defence of PHP, some Perl madness from Matt S Trout, a rant about multicore processors and a quick introduction to Access Space. Simon also managed a plug for Currybeer, amongst other geek groups in Manchester.
We also had a social programme which started on the Monday night with a few drinks, led into free beer (courtesy of antibodyMX) and curry on the Tuesday, a conference dinner on the Wednesday and more drinks on Thursday evening. This meant that I effectively spent 72 hours running a conference with no rest beyond three lots of 6 hours sleep, for which my immune system promptly punished me for the next three days.
Anyway, that’s Spring 2010 over, now to start planning for 2011…
posted by Paul at 11:12pm on Sunday 28th March 2010 | Comments Off
Debt Relief Bill
Apparently I’m responsible for it not going through! ![]()
posted by Paul at 8:55am on Tuesday 16th March 2010 | 1 Comment »
