My Ridiculous Source Code Backup System




One of the most frustrating things in the world being a developer is losing code. So there’s very few things that I make sure to take extra care in than source code backup.

One of the most frustrating things in the world being a developer is losing code. So there’s very few things that I make sure to take extra care in than source code backup.

Of course I use version control via subversion on a service called Beanstalk. Yes, I know that GIT is better, I just grew up on subversion.

First off, when I check out my repositories on my local machine, I have the repository directory nested in my Dropbox Pro folder. I have Extended History turned on in my Dropbox which means it keeps each and every version of each file for a year versus the standard thirty days.

Now comes the post-commit process. On every single commit, the following occurs:

  • Gets checked into subversion (with commit message required)
  • Automatically deploys on development server
  • Then on my local machine:
    • Tars the entire project and places it in a temp directory
    • Copies the project to my Google Drive
    • Copies the project to Dropbox
    • Copies the project to my 4 terabyte external hard drive
    • Copies the project to an Amazon S3 bucket in California
    • Copies the project to an Amazon S3 bucket in Virginia
    • Copies the project to an Amazon S3 bucket in Tokyo that has a lifecycle rule applied to automatically retire all files in that bucket to Amazon Glacier after 24 hours
  • Removes the tar archive from the temp directory

I realize that it’s a tiny bit excessive but I’m not lying when I can’t stand losing code.


Day One Script for Ubuntu

Since I have been developing a lot more lately, I haven’t been on my iPad as much. So when I pulled up Day One today, I was kinda sad to see that my last entry was over a month ago.

I know Day One has a macOS app but my preferred development enviornment is Ubuntu running on a Lenovo Thinkpad. Since I took the day off from working on Bob today, I decided to write a short python script to write journal entries directly from my Ubuntu terminal.

It was actually pretty easy, I just created a recipe in IFTTT to send a Webhook request and turn the information that I pass to it into a journal entry. The whole thing took probably forty five minutes. I still have to add things like image support but that will be another night.

I’m just happy I can quickly add text entries at the moment! 

#!/usr/bin/python

import requests

print "Entry title:"
title=raw_input()

print "Content:"

contents = []

while True:

    try:
        line = raw_input("")

    except EOFError:
        break

    contents.append(line)

text = '\n'.join(contents)

print "Entry: \n\nTitle: "+title+"\n\nContent: "+text+"\n\nSave entry? "

text = text.replace('\n', '<br /><br />')

save=raw_input()

if (save == "Y" or save == "y"):
    r = requests.post("https://maker.ifttt.com/trigger/journal_entry/with/key/xxxxx", data={'value1': title, 'value2': text})