Nick Gasper

This user hasn't shared any biographical information

Homepage: http://www.iphouse.com


Posts by Nick Gasper

Found Script: Backing up data with BASH and XZ

Quick post this week as I’m a little distracted by the impending weekend.

Here’s a script that I use to backup my Maildir. Normally I write my own, but I was feeling lazy. So in the interest of not re-inventing the wheel, I decided to copy one. Unfortunately, I forgot where I got it. Normally I’m good about attributing things that I copy/utilize. So, if this is your script, thank you! If you want attribution, please let me know.

This is just a bash script. It creates a xz’d tar file in my /home/nick/Archives directory/

First, check for input.’

#----script to backup files

if [ $# -lt 1 ]
then
   echo Usage: backup.sh Directory
   exit
fi

Next, create the date stamp.

JJJ=`date '+%d%m%y'`

This is the main loop. It processes for each in the attribute list ($#)

while [ $# -gt 0 ]
do

Print the directory we’re currently working on, then set the DIR variable to that directory’s path.

   echo $1
   DIR=$1

Truncate the directory path of the DIR variable

   MODDIR=`basename $DIR`

Verify the directory exists before doing anything

   #----check file exists
   if [ ! -d $DIR ]
   then
      echo Error: File \'$MODDIR\' not found!!

Check to see if the destination folder exists. This is where I hard coded it to be /home/user/Archives. If it doesn’t, create the backup locally.

   else
      if [ -d ~/Archives ]
      then
        DESTTAR=~/Archives/$MODDIR.$JJJ.tar.xz
      else
        DESTTAR=$MODDIR.$JJJ.tar.xz
      fi

Check to see of the destination file exists. If it does, complain and exit.

    if [ -d $DESTTAR ]
        then
                echo Error: File \'$DESTTAR\' already exists!!
                exit 0

Tar the archive using the xz compression method (the “J” attribute in the tar command)

    fi
      tar -cJf $DESTTAR $DIR
   fi
   shift
done

And we’re done! At some point I’ll add an auto-pruning portion to the script.

I just stick the script in my personal bin folder, make it executable, edit my crontab and put an entry in it pointing to my Maildir, and I get nightlly backups of all my mail.

Kickstart your Linux install

I’ll admit it, I’m not a huge fan of Red Hat Enterprise Linux. I’ll administer it, I’ve worked with it. It’s a good distribution. I just have a bad taste for RPM based distributions based on my first forays into Linux back in my Mandrake days. I also first started to professionally work with Linux during the last couple of years of RHEL 5, when things were getting long in the tooth. Red Hat’s release schedule also conflicts with what most of my users want and expect; it’s far more suited to an corporate environment where having the latest features is not nearly as important as having consistent software versions. That being said, Red Hat has some fantastic tools; Anaconda and Kickstart being my favorite. So I was overjoyed when I discovered Ubuntu had support for Kickstart files! The Ubuntu installer can take Debian style preseed directives but in my opinion is overly complicated.

A Kickstart file basically answers the questions that pop up in the installer as the installer goes removing the need for human interaction. If an question isn’t answered, the installer pops up with the proper dialog, takes user input, and continues. I can pick and choose what information I want to populate automatically and which information dialogs I want the customer to answer. In my auto install ISOs I prompt the customer for a username and password as I want the users to enter that information.

When I was tasked with making an auto installing ISO for our customers I was able to create one quickly by using a kickstart file.
More >

SysAdmin Golf: Use dd and netcat to clone a Linux machine

So, we’ve been working real hard here at ipHouse figure out ways to help customers move machines into our vmForge VDC product. VMware Converter works for Windows machines, (allegedly, I’m going test it soon) but isn’t so helpful with Linux machines. After wracking my brain, I thought about the various tools used to clone Linux boxes. I’m familiar with dd, a block level disk copying tool, and tried to find a way to use dd to create a VMDK, that I could then convert into a OVF and upload. More >

Infrastructure and Other Games, Part 4

Part 4: The Other Stuff

Thanks for reading my series on moving from my single all-in-one server and my small ESXi server to ipHouse’s vmForge VDC product. I previously discussed moving my websites to a virtual webcluster, and moving email to a virtual mailcluster. Now I just had to move three small servers, and install a third.

The first server I moved was a small experimental VM used for testing various network, web and other items. I like to have dedicated testing environment for every operating system that I professionally run. This server was responsible for my personal Teredo tunneling, and was the one I put my CGI testing on from awhile a go. I could have easily moved it, but I wanted see how the export/import from ESXi to vmForge worked. I stopped the machine on my ESXi server, downloaded it as a OVF and uploaded it, via my Windows machine, to my catalog. It imported it as a template. I then deployed the template and deleted the server. It worked flawlessly! All I had to do renumber the machine and I was done. More >

Infrastucture and Other Games, Part 3

Part 3: The Mailcluster

Last week I discussed creating a web cluster to take over hosting websites from my decommissioned server. I wrote about setting up the layout, load balancing inside of the firewall and performance testing. This week is about setting up a load balanced mail cluster.

More >