Backing Up, Starting Over, Seeing Success
November 24th, 2005 | by jg3 |It was often said about my late grandfather…
There are three ways to do things: the right way, the wrong way, and his way.
My mother and grandmother spent a lifetime learning how handle it when their husbands got into “Earl mode” and determined to do things in their own way. The gene that controls this is, unfortunately, very dominant. Having recieved this gene I have spent many frustrating hours of my life trying to do things in ways that make sense to me, suit my preference, and are ridiculous. In such cases it is often impossible for us to back up, reevaluate the situation, and take a new tack. Impossible because we become blind, solidly assured that our method, our solution has the maximum benefit.
I use “our” and “us” because it is helpful to blame my problem on genetics. Because it is somehow less obnoxious when I am not the only one who does this. Because if I can’t help it I can’t be made responsible for it. This is all wrong, but habitual. Pardon me. As the recipient of this gene I accept the mantle of Earl and the reponsibility for my own actions. Going forward this will not be considered explanation nor excuse for this behavior.
What follows is a perfect example from yesterday of how this gets me into trouble. The particulars of this may only make sense to you if you are a computer geek, but the story is the same. This specific example is so thouroughly documented because after spending so much time on it, I don’t want to forget what worked.
The unix system at work where my home directory lives creates a subdirectory called .snapshot and periodically copies the contents of the home directory, creating fifteen snapshots of its contents, stretching back through two weeks of time:
foo [bar:/homes/uu02/h/homedir/.snapshot]% ls
hourly.0 hourly.3 nightly.0 nightly.3 nightly.6
hourly.1 hourly.4 nightly.1 nightly.4 weekly.0
hourly.2 hourly.5 nightly.2 nightly.5 weekly.1
That’s all very nice and quite useful if I inadvertently delete some important document, but when I am going to create an offline backup of my home directory, I do not want to include the .snapshot directory tree. Without it, my home directory — including mail archives — are almost 1GB, why make it 16GB. The process for copying a directory is fairly straightforward (cp -r ...), but to copy “everything in the directory except…” is a bit different. Yesterday, I spent several hours trying to get various iterations of find -L home -not -path "*\.snapshot*" -exec cp -pv {} backup/ \; and even trying a little xargs magic, all without success (for reasons which are still not completely clear). After knocking away at this problem I looked out the window at about 8:30 pm and I had to call my brother to say “Dude! It is snowing! It won’t be long now before snowboarding season!” In that conversation he invited me to come have some wings with him and some of his friends. I decided that I had beaten my head against the problem enough hours for one day and went out for some chicken.
This morning when I woke up, my thoughts began to return to the directory copying problem and realized (this is critical) that I had been doing it all wrong yesterday. In fact, I should not be using find or cp, or even rsync (as suggested by one person I asked about it), I should be using tar! So, for posterity, here’s the command that eventually worked for me and the command that I used to verify that it seemed to work:
% tar --exclude="*\.snapshot*" -cf - csserve0/ | ( cd bACK/ ; tar -xpvf - )
% diff -sr csserve0/ bACK/csserve0/
I based the actual command I used on some notes I took dated January 20, 2001. This just shows how rusty my unix-foo is, but that is a topic for another post alone.
The take away lessons from this are:
- avoid getting stuck on just one solution
- evaluate all options; ALL options
- don’t
find -exec cpwhen you cantar - walking away from a problem sometimes helps solve it.
- save your notes
Sorry, comments for this entry are closed at this time.