Posted
Comments None

Settings Backup and Restoration with GitHub

A new Ubuntu version is coming out and the last thing I want to do is manually copy over my myriad of different config and settings files. I have my PS1 function set the way I like it, my Terminator terminal all set up with my keybindings and colors, some handy aliases, and some other rc_goodies. Thanks to the awesome power of GitHub, I fret of this aspect of upgrading no longer. I set up a repo that has a script that pulls in all my latest and greatest changes and can push those changes back out to my system.

The Backup/Restore Process

I have a python script that has a list of file names. For each file, it shutil.copyfile()’s the file to my current working directory under files/filename. There is one caveat. I change the filename from /path/to/file to slash__path__slash__to__slash__file. Upon restoration, I run the same script with a different flag for restoration. It changes those __slash tokens back to a good ol’ forward-slash and copies the file back into the place it belongs. Prior to restoring the file, the script checks to see if the file already exists, and if it does, replace it with filename.BAK.

On a New System

All I have to do is git clone my repo, and run ‘grab_settings.py restore’. Vim works the way I like. Terminator works the way I like. My aliases are all present. Done and done.

Author
Categories

Posted
Comments None

The Idea

At work, some of us are really thinking hard on different ways that we can improve the hiring process. One of the ways is revamping some of the questions that we ask candidates. With that in mind, a buddy on my team and I got to work. One of our thoughts was to make something that was still really easy, but better than standard academic style questions for managing lists/arrays.

We decided to create a couple of endpoints that return a JSON response with data that can be sorted, merged, paginated, etc. I took the opportunity provided by needing to make a toy application and decided that I would build my first Django application (bare as it would be), use PostgreSQL for the first time, and host my first application on Heroku.

Pain Points

Django so far is awesome. And I’m really impressed by what Heroku has going on. I followed the directions on the Heroku site line by line and quickly had a ‘hello world’ page up. However, there were some issues.

First, getting PostgreSQL going for the first time was a bit frustrating. Their ‘Getting Started’ docs are a little light on some super basic info that I did not have. I install the software on my Ubuntu system. Cool. I go to create a database and table using the command line and … BAM. Can’t be done. I don’t have a role for my system username. Ok, so I search PostgreSQL’s docs for adding roles. No problem, I just need to run some direct SQL. Well, and it is probably me, I could not find anything on what the actual command line was to open PostgreSQL. After some Googling, I discover that it is simply the psql command. Cool. I enter it. Role problems still. Well. Hmph. After some sleuthing and more doc reading, I realize that I have to go in with the Postres user. a ‘sudo -su postgres’ later and now I can add the role for my username and be free to use ‘psql’ from the command line in a sane fashion. Sheesh.

Second, Heroku. I get the models set up for my Django app. Everything looks good on my dev side. I push up to Heroku. I realize that I need to run a dbsync. I do that locally and it explodes. Engine issues. I realize that the tutorial from Heroku had me overwrite the database settings for Django and that seems to be the problem. After some more digging, I realize how to set the default database info for Django in accordance with Heroku’s added code. Everything seems to be working. Push up to Heroku. No go. Hmm. It took some more time to realize that I have to manually set the DATABASE_URL environmental config for Heroku. Heroku provides the database info in a different config variable. If they would have mentioned it in the setup docs, this would not have been such a royal pain in my ass. Not quite thirdly, one solution that I tried to explore had me run ‘heroku addon….’ To which the heroku application said there is no ‘addon’ command, and offered that perhaps I mean ‘addon’ instead. WAT?

All’s Well that Ends Well

While there was the pain points, I’m all up and going and more wiser than before. It would have been a whole lot less frustrating though had Heroku and PostgreSQL had just a tad more documentation. A few minutes on their part would have saved me a metric-tonne of time.

Author
Categories

Posted
Comments 1

What do I want to get out of this?

I’ve been thinking for a while now that I need start writing more regularly. Writing helps organize thoughts, preserve ideas, and fosters creativity for the author and reader. While I’m at it, hopefully I can really identify a tone that is “me” in my writing. I know the whole “how to write a good essay” template that you learn in high school and abuse in university. I felt that, however, through those writings, I never got to be me. With no efforts here graded — or likely read at all — I can just write what is on my mind or what is going on. So, in short, this blog is here for:

  • An excuse to start writing more
  • A place to spur thoughts
  • A dumping ground

Author

← Older Newer →