Cisco Email Config Backup
ET fone home... using email config backup
This is a nice little feature that most cisco routers have to allow simple cisco config backup Since I didn't want to install a messy service like RANCID or sftp servers just to get cisco configs, this is a light weight solution for getting the cisco to mail you its own config once in a while.
call-home
contact-email-addr mark@cisco_router.com
mail-server your_mail_server priority 1
profile "ConfigBackup-1"
destination address email mark@xxx.com
subscribe-to-alert-group configuration export full periodic monthly 11 10:00
This cisco will mail you once a month on the 11th at 10am.
Innobackupex a faster MySQL re-slaving process (Ubuntu)
A shoutout to my friend Colm for putting these instructions together, I'm putting it here for easy access. The following contains simple steps for re-slaving a broken mysql slave by using innobackupex. I've cleaned it up a bit for conciseness. This procedures uses the Percona tools for a much quicker master to slave sync. MySQL dump just takes wayyy to long.
Innobackupex is a Percona tool which does a binary copy of the raw MySQL data files adjusting for transactional integrity. This process is a lot faster than the standard mysql dump + load + slave option. We have been using this in production for a while now.
Prepping using innobackupex
# if the package hasn't already been installed:
master# sudo apt-get install percona-xtrabackup
master# cd ~ && rm -rf mysqlbak/ && mkdir mysqlbak/
# To avoid issues if your connection breaks
master# screen
# reduce the I/O impact on MySQL funtioning
master# nice -n 19 ionice -c3 innobackupex mysqlbak/
# Clean up the transaction so the database is consistent
master# innobackupex --apply-log mysqlbak/*
master# ssh backupserver "rm -rf mysqlbak/" && scp -Cr mysqlbak/ backupserver:
Start up the slave
slave# service mysql stop
slave# mv /var/lib/mysql /var/lib/mysql_old
slave# mv mysqlbak/* /var/lib/mysql
slave# chown -R mysql:mysql /var/lib/mysql
# The following file has to be present in the data directory
slave# cp /var/lib/mysql_old/master.info /var/lib/mysql/
# Update Offsite slave root password from the Master DB password
slave# mysqladmin -u root -pMasterPassword -S /var/run/mysqld/mysqld.sock password 'OffSiteSlavePassword'
slave# service mysql start
# Setup Slave configuration
# This file contains the master_log_file and master_log_pos information
slave# cat /var/lib/mysql/xtrabackup_binlog_info
slave# mysql -e 'change master to master_log_file="xxx", master_log_pos=yyy;'
slave# mysql -e 'start slave;'
slave# mysql -e 'show slave status\G'
Useful Links
This procedure has brought a previous 12 hour+ restore process down to 2 hours.
Percona Toolkit
Innobackupex
Vagrant + VirtualBox + Puppet on OSX (Rapid puppet testing)
Hello,
I'm a massive fan of Puppet, its made my life so easy. At the same time Puppet is very powerful when you give it full control of your entire systems. One of the things thats been lacking in my environments has been the ability to quickly test Puppet code destined for production and see how it fares. This is where Vagrant and VirtualBox comes in :D
Quickly, quickly I need to be somewhere else
# (Optional) Homebrew which gives you access to useful packages.
Download and install Homebrew
# VirtualBox which is kinda fundamental to this.
Download and install VirtualBox
# Installs vagrant, puppet and puppet-line (puppet style checker)
sudo gem install vagrant puppet puppet-lint --no-ri --no-rdoc
# Downloads a Ubuntu 12.04 LTS image to work off (google for your poison)
sudo vagrant box add precise64 http://files.vagrantup.com/precise64.box
# It also sets the correct permissions to run vagrant
sudo chown -R localuser ~/.vagrant.d
I choose to install vagrant, puppet and co through gems because there's enough package management crap on my system as it is without me introducing more pain :)
Can I do something now
# This is the folder you want to work one set of VM's out of
mkdir vm_working_dir
# Let Vagrant do some magic
vagrant init
# Edit the VagrantFile (see below)
# Add a bash file (see below)
Add a bash file to setup basic stuff on my new 12.04 LTS
#!/bin/bash
hostname xxx
apt-get update
#apt-get upgrade -y
apt-get -y install puppet
This is powerful because you can set the hostname to which ever box in production you would like to mimic/test.
Edit VagrantFile to look like this:
# This refers which base image to use, our previous downloaded precise64
Vagrant::Config.run do |config|
config.vm.box = "precise64"
end
# This can be any arbitary script covered above
puppet binary e.g. apt-get install puppet
config.vm.provision :shell do |sh|
sh.path = "base_setup.sh"
end
# I pointed module_path to my local modules folder.
# I setup a custom facter fact to set vagrant variable (useful, more later).
# I pointed the manifest file at the top level puppet file so it includes my whole tree.
config.vm.provision :puppet, :facter => { "vagrant" => "true" }, :module_path => "~/puppet/modules" do |puppet|
puppet.manifests_path = "~/puppet/manifests"
puppet.manifest_file = "site.pp"
end
Lets fire this baby up...
cd vm_working_dir
# starts up vagrant and new base image the very first time
vagrant up
# If your VagrantFile is correct, it will:
# Copy the precise64 to start your local image
# Setup fundamental networking
# Run the bash script on it once its up
# Run the node against my own puppet manifests based on its own hostname
# once its all fired up
vagrant ssh (this drops you onto the box)
# Shuts down the box once you are done all state is preserved for later use
vagrant halt
Explain damn you!
- I prefer running it just on my local puppet files rather than through another local puppet server + new server CA + new client cert + *vomit*...
- The reason I added my own Puppet facter fact is because you don't want your local vagrant box applying production network/security settings that might prevent "vagrant ssh" to work.
-
Now that this is setup, you can just run Vagrant destroy + Vagrant up to build a box from base OS image.
-
If running a full base build is too time consuming and unnecessary just shutdown using vagrant halt and vagrant up to apply the latest changes...
Useful stuff
# This will start you up from scratch and destroy anything puppet and bash script did
vagrant destroy
# This will delete the image you downloaded...
vagrant box remove precise64
- http://puppet-lint.com/
- http://rspec-puppet.com/
- Let me know if I've missed anything.
When I get a chance i'll put up an article on puppet continuous build and release. I <3 Vagrant!
How to use your Android phone as a pc
So for anyone who doesn't know, the Samsung Galaxy SII is quite possibly the world's sexiest phone.
I'm in love with Android, and wouldn't have it any other way.
I'm also a big proponent of mobile devices in general and believe they will supersede personal computers in the next 5 or so years.
To test my theory of how relevant this was, I used only my phone at home for 3 months. No PC or laptops.
The result was... interesting. I was amazed at how much I could do, but my battery hated me.
It now only lasts about 60% of what it used to brand new. This was quite easy to fix as I just bought a few new ones.
But the critical part of how I was able to do this was the use of a few clever gadgets. The crux of which is a new standard called MHL.
It allows you to link your phone to your TV via a small cable which also has an adapter for the charger.

With this little connector, you can blow your phone screen on to any size TV over HDMI, and watch full 1080p videos on it. It is thus also your entertainment centre... in your pocket.
I also acquired a Bluetooth keyboard and mouse which worked perfectly with the phone.
You have many choices for the keyboard including an apple keyboard, the fabulous Logitech Dinovo mini or various other ones from ebay.
For the mouse, I chose a Logitech V470, but any Bluetooth mouse would have done fine.
This allowed me to play music, write documents, surf the web, and do pretty much anything I would normally do on a PC. Since Android also has support for flash, all websites render just fine on the device.
This opens some interesting doors for the future, and I'm very excited. Imagine having all your files in the cloud ready to be downloaded over high speed 4G internet anywhere you are. When you get to work, you plug your phone into your monitor and you are ready to go. Get home, plug it into your TV and watch a movie in 1080p, browse the net, and catch up with some friends. All your computing needs in the palm of your hand. We are so close. I can't wait.
First gen Macbook Air weak link
Just spent a large part of tonight trying to figure out why my macbook air had spotty wifi connection... it was driving me insane!
I finally tore it up and found two wires broken from the hinge body of the air. Manually joining the b0rked wire changed wifi condition from 50% packet drops to 900 kb/s rsync. Anybody know why the wifi wires are so thin? I'm thinking of soldering it back, but i'm worried about the thinness of the connections. Is there a better way?
Update: I soldiered it two lines today and full wireless strength now w00t!
New headphones!
After a 6 hour research marathon, I finally decided to plonk down for a pair of Etymotic Research hf2.
I've now had them for a good week and have tried every pair of the 4 different buds that come with it.
I went in knowing that it would be bass light, but great clarity on the high/mid end. But my logic was that if I want more bass, I can simply equalise it in.
So.... not quite.
The good news is, it has utterly phenomenal clarity. Every breath, every word is "crisp" as ice. And the noise isolation is absolutely incredible.
I've used the ER's signature triple flange before so I'm very used to the incredible vacuum seal/noise isolation it creates.
You will hear nothing of the outside world.... Seriously. Someone could be shouting in your face and you'll see their mouth moving, but no sound.
Now to the flaw in my super plan. The bass is... lacking. There, I said it.
The first thing you see when you open the pack is this "warning! you must create a seal for bass"... which, I've clearly got, since pulling them out feels like I'm bringing a bit of my eardrums with it.
But what about EQ?? Just pump up the lows you bass head!
Well, I did, and to my dread I got mud. The lows go muddy as soon as you bump it up beyond about 10-15%. These were clearly not able to reproduce the lows at a significant level.
I triple checked this by comparing the sound to my ageing PX100 and my Grados.
The result was that both of them produced the bass perfectly even with the lows jacked to the heavens.
To be honest, this was my own fault. I tried to have my cake and eat it too. There was simply no way a single driver in-ears was going to reproduce both crisp highs and deep lows. Something had to give.
So would I recommend them? Yes, somewhat. I'm still well within my refund period, but I'm definitely going to keep them.
They are great for most songs and for audiobooks/podcasts, especially on the train.
But I'll be using something else if I want alot of bass.... maybe I'll go try a pair of Shures.
TL;DR - Fantastic highs/mids, excellent noise isolation, poor/muddy lows. 8/10
Deployment strategy and symbolic links
Here's a quick neat idea involving using symbolic links on a production environment.
A most basic deployment strategy usually involves taking your site down, upgrading your database/files either manually or through svn.
Some more sophisticated strategies may involve tools such as phing (for php).
But there can be some problems, most of all the fact that the site might have to be down while maintenance is going on.
A better way to do this is to have your production environment sit on a symbolic link.
You can then deploy the new version to an entirely new directory and test it to make sure everything is fine, and then instantly switch the symbolic link to the new version when you are ready to release it.
If the flak hits the fan and you need to revert back, simply point the sym-link back to the original directory.
For example, lets say your site is currently on version 1.4, and you are upgrading to 1.5. The files might be here
/var/sites/mysite/version1.4/
Now copy everything from the above directory into:
/var/sites/mysite/version1.5/
Do your normal release strategy on this new directory.
Your symbolic link might looks something like:
/var/www/vhosts/mysite.com -> /var/sites/mysite/version1.4
/var/www/vhosts/staging.mysite.com -> /var/sites/mysite/version1.5
Once you are happy to do the switch, simply point the link to the same place as your staging environment
/var/www/vhosts/mysite.com -> /var/sites/mysite/version1.5
Just doing this is great for mostly read only content and no database changes.
Next up I'll write up something which deals with database changes and how to have a site that never goes down, even when complicated maintenance is required.












