What I’ve been up to recently?

20 10 2009

Well, the true answer – not much.

I’m fairly happy with my linux setup right now – atleast, I haven’t felt the burning urge to distro-hop away from Arch Linux. However, hardware-wise, I’m extremely unhappy. Infact, it’s more than that. I’m angry. This laptop is a load of bum. However, I’m at a time where buying a new laptop, although economically sound, would just be silly. Reasoning here: Well, I’ll be going off to university next year (yeap, to study Computer Science), for which I’ll need a decent laptop for research and what-not. Buying one now will just cost me about £500, where as holding off till next year will cost me £500, but for a better-equiped laptop. So for now, I’ll hold up with this heap of black-plastic’d Dell rubbish.

I have also recently taken down my linux file server. I found it to be too much hassle. It wasn’t going to plan in it’s last few weeks – None of the automated scripts ran properl, I ran into some FileSystem integrity problems which meant that it could crash at anytime, taking out all the media held on it. Also, it has some serious hardware problems – It kept rebooting. However, this shouldn’t come as such a surprise – It was ancient. 667MHz Celeron isn’t something to mourn over. However, a fully functioning SSH, file and music server is.

So my plan is to save up some spare dosh, and buy a cheap barebones kit. I’ll then install Linux (maybe Debian or CentOS this time) onto a fast USB flash drive, and use that as root. I can then buy a 1TB drive, or maybe just a 500GB hard drive, and use that purely for file storage. Might even buy two identical drives, and set them up in a RAID configuration, to safe-guard my precious media.

Do you have any tech ideas? Whats your next move? Let me know in the comment section 🙂

Backing up is easy with Rsync

21 08 2009

“Always backup regularly!” is a bit of a mantra in the online linux community. You can see where they are coming from though. How many problems have you read about or posted on forums which could have been solved or avoided had there been a recent backup made? Lots.

Although they always bash you for not making regular backups, they rarely tell you how to make the backups.

As daunting as backing up sounds, it really isn’t hard when you have the tools. One of these tools is Rsync. Rsync is an amazing backup utility. Its flexible, open source, and is really reliable. It can be used for local backup – backing up a local file or directory, to another local directory or mounted filesystem, or it can be used for remote backup – backing up a local file to a remote server, or a remote file to a local directory.

In this article, I’ll be focusing on remote backups, using rsync to backup important files and directories to a remote server over SSH. However, with a little tinkering, you can easily mold this into local backups, if that takes your fancy.

0. Install rsync

You’ll want to install this on both client machine and server. This allows you to take advantage of rsync’s two backup methods – “push” and “pull“. “Push” sends a local file or directory to a remote server, whereas “pull” grabs a remote file or directory, and stores it locally, all of which is done over SSH.

1. Configure

While rsync itself needs no form of configuration, we need to be able to SSH into our remote machine, preferably without a password. If you haven’t already set up SSH, you should check out OpenSSH. There are many guide around the vast stretches of the interwebs. I may even publish a guide myself on here some day.

It’s fairly simple to set up passwordless login of SSH. Simply generate a set of SSH keys on the client-side, then give them a blank password. From here, you send the id_rsa.pub or id_dsa.pub file over SSH to your server, using the scp tool, or even ftp if your old school. After this, SSH into your remote machine, add the contents of the .pub file to your “authorized_keys” file in the ~/.ssh directory (if it doesn’t exist, create it using “mkdir ~/.ssh/” and “touch authorized_keys”). (To add the contents of the .pub file, simply “cat id_rsa >> authorized_keys“. Then we simply configure the SSHd confuration file to allow SSH access via key authentication.

2. Backing up

Now that everything is in place, we can start backing up important documents and directories!

NOTE: Rsync won’t create a destination directory if one doesn’t exist. You must mkdir your destination directory before using rsync.

If you are using the “push” method (my preference), all you need to do is run this command. As always, I’ll show you the command, and then break it down, making it easier to understand.

rsync –progress -avz -e ‘ssh -p[port]’ /directory/or/file/to/backup user@serverIP:/directory/to/backup/to/

Rsyncis rather obvious. “–progressgive you a progress report along the way. -avzis a mixture of option for how the data is to be handled. astands for archive – this means that permissions and ownerships and whatnot is all preserved. This also means that the directory is sent recursively, ie all the files in all the subdirectories are also sent, with the directory tree preserved. -vstands for verbose – this just increases the output of the command, depending on how many v’s are present (useful for debugging a problem). ztells rsync to compress the data before sending. This speeds up the backup. [port] should be replace with your SSH port. User should be replaced to your main SSH user on the remote host, ie the user you want to use to backup the files. ServerIP should obviously be replaced with the IP address of your server.

For the “pull” method, simply insert your source directory/file as you would with SSH access. ie

rsync –progress -avz -e ‘ssh -p[port]’ user@IP:/file/to/backup /local/directory/to/backup/to/

NOTE: The existence of a slash at the end of the source directory (the first specified directory or file) is significant to what rsync does. It a / exists, then rsync backs up the CONTENTS of that directory. However if the slash does not exist, then the folder itself is sent.

There we have it. A little guide on how to back up remotely. I hope this helped somewhat.