Monday, February 13, 2017

mutt print to pdf one liner

set print_command="iconv -c -t ISO-8859-1//TRANSLIT | enscript -B --word-wrap --font=Times10 $1 -p - 2>/dev/null| ps2pdf - /tmp/test.pdf && evince /tmp/test.pdf"

posted by admin at 9:26 pm  

Saturday, February 11, 2017

Time Machine backups on DreamCompute

I really like the simplicity of Time Machine for backing up my Macs. It makes restoring lost files and changing computers extremely easy. However, my laptop is rarely on my home network so it would go months without completing a full backup. My solution was to set up an openvpn server and bridge it with my home network. This allowed my laptop to appear as if it was on my home network regardless of where I was connected. This also allowed me to print to my network printer and VNC to machines on my home network when I was away. I also set it up where I could, when needed, tunnel all traffic through my home network so traffic would be encrypted even if I was on a public unencrypted wifi network.

I had been using BackBlaze for offsite backups but I wanted to see if I could get offsite TimeMachine working. A few notes before I get rolling:

  1. This uses a lot of bandwidth for initial backup. I was saturating my 100Mbps FIOS connection before I started packet shaping. However, incremental backups are usually small so it isn’t much of an issue after initial backup.
  2. If you follow the directions below, you can’t do a full system restore from it as a local VPN connection is required. So, if something happened to both your computer and your local backup, restoring would be still be possible but more complicated as you would need to copy the sparse image somewhere local.
  3. If you have a large (>100GB) amount of data to back up, this can get expensive as only 100GB is included with a DHC account.
  4. This should not be your primary backup. Because of the latency, browsing and restoring files lags a bit.

Setting up a server

I will be setting up an Ubuntu instance on DreamCompute. On that instance, I will be running an OpenVPN server, an AFP daemon, and an avahi daemon.

The first thing you need to do is create an Ubuntu 16.04 instance using the directions here. Even while backups were running, I never exceeded a load of .5 on a single proc instance or more than 100MB of RAM so a semisonic instance is more than powerful enough.

You need to create a volume for the backups to be stored on and attach it to the instance you just created. Make sure the volume you create is at least as big as the drive in the computer you are backing up. You should only use this volume for backups as Time Machine will grow to use all the space you give it to store incremental snapshots. Follow the directions here to set up a volume.

You also need to open up UDP port 1194 for your OpenVPN connection. Instructions for setting up a security group on DreamCompute are here.

Install dependencies

Now that we’ve got the server up and running, first thing we need to do is install needed dependencies!

sudo su
apt-get install openvpn easy-rsa netatalk avahi-daemon

Create and attach volume

Partition and format your volume. I used xfs but it doesn’t really matter.

parted -s /dev/vdb mklabel gpt mkpart P1 xfs 0% 100%
mkfs.xfs /dev/vdb1

Create the direction where you want the backups stored.

mkdir /mnt/backups

Edit /etc/fstab and add a line for your backup mount

/dev/vdb1 /mnt/backups xfs defaults 0 0

And get it mounted.

mount -a

Set up users

While it is possible to store all backups under the same user, I find it easier to manage backups if each computer’s backup is stored under its own user. For each computer you want to back up set up a user.


adduser luke
mkdir /mnt/backups/luke
chown -R luke /mnt/backups/luke

Set up certificate authority and generate keys

For computers to be able to connect to your OpenVPN server, you need to set up a certificate authority.

mkdir /etc/openvpn/easy-rsa/
cp -r /usr/share/easy-rsa/* /etc/openvpn/easy-rsa/

Edit /etc/openvpn/easy-rsa/vars and update the values to match your information.

Build the certificate authority

cd /etc/openvpn/easy-rsa/
source vars
./clean-all
./build-ca
./build-key-server timemachine
./build-dh
cp timemachine.crt timemachine.key ca.crt dh2048.pem /etc/openvpn/

Now, generate a key for each of the computers you wish to back up.

cd /etc/openvpn/easy-rsa/
source vars
./build-key luke

Copy ca.crt and the generated files to each machine you are going to be backing up using scp or rsync.

/etc/openvpn/ca.crt
/etc/openvpn/easy-rsa/keys/luke.crt
/etc/openvpn/easy-rsa/keys/luke.key

Next we have to set up the OpenVPN server itself. Copy the sample server config file and decompress it into /etc/openvn

cp /usr/share/doc/openvpn/examples/sample-config-files/server.conf.gz /etc/openvpn/
gzip -d /etc/openvpn/server.conf.gz

Edit /etc/openvpn/server.conf For timemachine you want it to be a tap device, not tun so remove the semicolon from behind “dev tap” and add one behind “dev tun”.

dev tap
;dev tun

You also need to update ca, cert, and key to point to the correct files.

ca ca.crt
cert timemachine.crt
key timemachine.key

OpenVPN configuration is done. Time to start it up!

service openvpn start

Set up AFP

TimeMachine requires either a local disk or a disk mounted via AFP or SMB. AFP will be deprecated once apple moves to APFS. Unfortunately, as of the writing of this blog, the SMB implementation in Ubuntu doesn’t support an extension that TimeMachine requires. You can check https://bugzilla.samba.org/show_bug.cgi?id=12380 to see if that has changed. So, we will be using AFP here. Luckily, the default install includes a config file for Apple volumes we just have to tweak it for our setup. Edit /etc/netatalk/AppleVolumes.default and add this line:

/mnt/backups/$u "Time Machine" options:tm

Now you just have to restart the service!

service netatalk restart

Set up avahi

The last thing we have to set up is avahi. This is Apple’s zeroconf networking protocol that will allow our Mac to find the server to back up to it. There’s no configuration changes we need to make sure. Just start the service.

service avahi-daemon start

Set up OpenVPN on mac

While you can use the OpenVPN command line client or TunnelBlick, I have found Viscosity much more powerful and easy to use.

For address, use the ip of your DreamCompute instance.

We will be moving a lot of data over this connection. Make sure LZO compression is on.

Use the ca, cert, and key that you copied over earlier.

Start backups!!!

From System Preferences, go to Time Machine. From there click “Add Backup Disk.” Select the TimeMachine mount you created and the backup will start!

If you ssh back into the server, you should be able to see the sparse image.

ubuntu@timemachine:/mnt/backups/luke$ ls
Luke.sparsebundle Network Trash Folder Temporary Items

posted by admin at 9:37 pm  

Friday, December 25, 2009

Rudolph Got Run Over by my Grandma

My father wrote this song. It is a parody of  “Granda Got Run Over by a Reindeer” and “Little Old Lady from Pasadena.” Merry Christmas and enjoy.

RudolfGotRunOverbymyGrandma

Lyrics copyright 2009 Anthony Odom

posted by admin at 8:32 am  

Monday, December 21, 2009

Merry Christmas to all

Hope everyone has a Merry Christmas and happy holiday season. Here are a couple videos of Christmas music I like. Enjoy.

posted by admin at 6:13 pm  

Saturday, July 25, 2009

Installing a street lamp . . . in my house

So, Joy and I lived in a very poorly lit apartment for 2 years. No matter how many lamps you put out, it was still dark. When we arrived at our new apartment in California, we were distressed to find out that neither the living room or the bedroom had ceiling lights. A couple days ago, while walking through The Home Depot, we spotted a display of street lights. (All pics taken from my iphone)

After analyzing the wiring, mount, etc., I decided I could “refit” an outdoor street lamp into an indoor street lamp. I assembled the lamp per the instructions up to the point of mounting it. I have a ton of old computer power cables laying around so I grabbed one and cut it open in order to splice it to the power of the lamp. Instead of the black, white, and green I was expecting, I got brown, blue, and green/yellow. I researched it and realized that those were European wiring standards (I have no idea where I got a European cord.) I wired brown to black, blue to white, and the bare cable to the green/yellow.

These were designed to be sunken into concrete, not be free standing so I had to make a base for it. I got a piece of scrap lumper from The Home Depot and made the base depicted below. Holes are for the bolts. Power cable goes through center hole and out the back. (Diagram made using Dia, a free diagraming program.)

While at Lowe’s I also bought I hand saw 😀

Below is the finished top piece.

It has scared Joy’s grey cat. He is running and hiding.

We now have plenty of light in our living room.

A close-up of the base.

As you can tell, it ain’t pretty. I am leaving the decorating and hiding of the base to Joy 😀

posted by admin at 4:23 pm  

Monday, April 27, 2009

Random Text Messages a.k.a. why 12-year-olds shouldn’t have cell phones

The last couple days I have had some interesting text messages and calls. These are all from the same cell phone number.

April 26, 2008

4:49 p.m.  Call: They hang up when I answer

5:55 p.m. Text message: Hey

7:56 p.m. Call: They hang up when I answer

8:02 p.m. Hi this is *******, ALLCAP’s DAUGHTER!!

8:18 p.m. ALL i have to say is you BETTER LEAVE her ALONE!

9:12 p.m. DO YOU GOT IT’? you better stay away

Text messages end. I assume they have realized their mistake. I didn’t respond because I assumed it was a joke/prank/junk message or something trying to get me to respond to make sure my number was valid. I had no idea whose number it was so I just left it alone . . . until today.

April 27

2:19 p.m. Text: Hey who is this??

I was tired of getting these texts so I decided to have a little fun and tell the truth.

2:21 Text from me: None of your business

2:22 p.m.  Text: Well it is seein that you have been textin my mama

I decided to be obstinant

2:24 Text from me: I will text who i want 2 text

2:27 Text: Well all I have to say is you better stay away from her

Not wanting to have some anonymous person tell me who to hang around with I respond:

2:29 Text from me: I will hang around wherever I want to hang around

2:30 Text: Oka well you wont be when my daddy other known as her husband gets done with you.

As this point I am fearing for the life of whoever is messing with XXXXXX. They are about to get beat up with no warning at all 😀 So, I respond:

2:54 Text from me: I think you have me confused with someone else. I have no idea who XXXXXXX is.

3:10 Text: Oka i’m tellin my daddy and then i’m telling my mama i kno and she will get rid of you

3:15 Text from me: You really have me confused with someone else.

3:20 Text: That is a lie!!

5:35 Text: I kno that its you i’m not an idiot unlike you

7:13 Text: Just incase you didn’t understand me earlier if you ever text my mama again you will regret it big time

Well I was going to leave it alone but I have been called a liar, an idiot, threatened, and it appears that ******* is not going to believe I am not texting her mother. Since she is threatening me, I might as well figure out how my destruction will play out.

7:22 p.m. Text from me: How so?

7:24 p.m. Somehow she has a family with a 12 year old daughter That’s me and a 14 year old son and a husband

Soooo, I’ve been tormenting a 12-year-old. I almost feel bad. I will once again try to convince her she is very comfused.

7:29 p.m. Text from me: I promise u i have no idea who your mother is. U have me confused with someone else.

Finally, she believes me.

7:37 p.m. Text: Well then why have you been agreeing with me the whole time??

9:02 p.m. Text from me: Actually, I haven’t agreed with anything you have said

9:05 p.m. Text: Well why didn’t you stop be at the begging??

I have decided to be completely honest with the poor gal

9:09 p.m. Text from me: I honestly thought it was a prank at first

9:10 p.m. Text: Sure you did

Considering how long it took me to convince her I was not after he mother I have decided to just drop it.  I have had a good day of amusemnt. The two morals of the story are don’t cheat on your husband and don’t let your 12-year-old have a phone.

posted by admin at 11:23 am  

Monday, January 12, 2009

Random thoughts

My name is Luke Odom (as if you didn’t know from the URL). I have an undergraduate degree in Information Systems and I am working on my graduate. This blog is my random thoughts on pretty much anything but probably centering on IT. Well, that’s all for now . . . until next time.

posted by admin at 3:55 pm  

Powered by WordPress Copyright © 2011 Luke Odom