Site Sponsors:
Incrementally Backing Up Changes to a USB Drive in Linux 

Saving Changes Anywhere?


Whenever we want to back up a Linux file system to a FAT / FAT32 file system, strange things can happen!

The need was to help us incrementally, and recursively, back-up file changes made during the past few days to a huge USB drive. -Since FAT partitions do not have all of that POSIX info, we were getting tired of waiting while absolutely everything was being copied over - even things that had not changed.

Unless you want to re-format the FAT partition to use NTFS (or EXT`n`), then there are two techniques here. The first technique also creates an on-line archive. The second works a lot like Mr. Bill's xcopy.

Technique 1: Coding It


Because the following script uses tar rather than cp, your file dates and time stamps will be preserved. Even ctime, mtime, or atime ... all the time!


#!/bin/bash

file_name="`basename $0`"
days='7'
file_tar="$HOME/$file_name.tar"
file_tar_list="$HOME/$file_name.found"

source="$1"
dest="$2"

echo 'Started at' `date` ", looking for deltas within $days days"

echo 'Source = '$source', Destination = '$dest
echo 'TAR file is ' $file_tar
echo 'FIND file is ' $file_tar_list

echo ' '
# echo 'Cleanup started at ' `date`
# $(find $source -name *.class -print -exec rm '{}' \; )
# $(find $dest -name *.class -print -exec rm '{}' \; )

echo ' '
echo 'Tar-up started at ' `date` ' from ' $source
pushd . > /dev/null
cd $source
find . -type f -mtime -$days -print > $file_tar_list
tar cvf $file_tar -T $file_tar_list
popd > /dev/null

echo ' '
echo 'Un-tar started at ' `date` ' to ' $dest
tar xvf $file_tar -C $dest

echo ' '
echo 'Completed at ' `date`



Since I have been writing a lot of Java this decade, I included a way to remove all of those pesky .class files. Just remove my # comments before those first find statements if you have a similar need.

Calling It


Once you copy the above into a file name (such as _io_sync.sh in the below,) all you need to do next is to call it. The _io_sync.sh script expects a pair of folders on its command-line:


#!/bin/bash
clear

source='/d_drive'
dest='/media/PATRIOT/d_drive'

file_name="`basename $0`.rpt"

./_io_sync.sh $source $dest | tee $file_name


Designed to be reflective, you can even swap the source and destination file around with impunity:


#!/bin/bash
clear

dest='/d_drive'
source='/media/PATRIOT/d_drive'

file_name="`basename $0`.rpt"

./_io_sync.sh $source $dest | tee $file_name


Of course, it is of no importance if we use the above on CentOS, Ubuntu, Slackware, or DSL. -This backup routine will work the same wherever a console / terminal / command-line / secure shell / or other script-running shell interface is available.

Left-Overs


Perfect for pen-drives, hard disks, or other mountable media, this script will leave a copy of the .tar file on your hard-drive in your home directory ($HOME) after all is said and done. A copy of the report file will also be placed right next to the script for your perusal & retroactive peace-of-mind, as well.

Technique 2: Preservations


If you do not want to have an on-line archive laying around, then you can just use:


#!/bin/bash
for arg in "/my_folder1" "/my_folder2"
do
cp -r -u -v --preserve $arg "./"
done


Simply copy & paste the above into a file, mark that file as executable, then modify and copy the script to where you would like the backup to store YOUR folders - like on a USB drive.

Best of all, note that running the operation repeatedly will only copy the 'deltas' (changes,) not everything else.

Conclusions


Clearly both techniques are superset operations: The only potential down-side is that previously deleted files will still be left hanging-around your backups. So if you want verbatim archives, then either delete the backup folders from time to time, else copy the tar file, as described earlier, to your backup device.

Finally, note that the above operations also work the same on NTFS, as well as on all EXT-n, partitions.

Enjoy!

R.A. Nagy


NOTE: If your are backing up to a POSIX file system and want to keep a log, then you might want to also consider this article.


Before any backup strategy however, don't forget to watch for, as well as reclaim any Zombies!

[ add comment ] ( 2267 views )   |  permalink  |  related link
The Ideal Company Structure? 
LinkedIn Question: "How do you see an ideal structure of IT company? Who reports who? What's the most effective division?"

Response: The problems I see today have far more to do with leadership, motivation, integrity, and ability than with the enforcement of any static hierarchies.

That said, in general I have noted that in between any corporate team"s top (brain) and bottom (hands) that there is often a gap. I believe that the best organizations usually have a way to support, attract, or encourage a hands-on evangelist. One who can bridge the gap between (for example) the boardroom, and the trenches.

Never exclusively an architect, yet never truly a sergeant, the best practice is to grow or recruit people who have a passion for the work, as well as a driving need to tell the truth.

While the passion for completing any task properly can be hard enough to locate, the ability to keep telling everyone the truth often requires that your evangelists have either a superior moral, if not financial, reserve to fall back on. "While wage slaves make extremely marvelous "yes men", they seldom have the intestinal fortitude required to tell everyone the truth, even as they see it.

In short, there is no "magic structure" to find or to enforce. Instead, I believe that the more successful, motivated, and honest the people one has to work with, the better any company will be.

[ add comment ] ( 2082 views )   |  permalink  |  related link
Sharp Objects 

Helpless


It was late. So late in fact that there was no-one standing anywhere near me in the security line.

That fact, coupled with my unfortunate tendency to arrive hours before my departure time (so I can write freeware or articles like this one), meant that I had time to spare; Even a bit too much time, tonight.

Looking up at that anonymous shadow behind the x-ray scanner, I greeted my lone inquisitor: "Finding anything interesting"?

"never do!" murmured the man.

"Kinda makes you wonder why we bother." Said I.

"A professional deterrent" said he, ever looking down, yet smiling to himself furtively.

"Even so" I mused "there are plastics, ceramics, and hidy-holes that will ever evade detection. Cuts from plastic picknick knives from Wal-Mart can kill someone" I have even seen KFC-lunch slices that required stitches."

"We know" said the guard. "But even saying that should earn you a strip search" he laughed, looking down at me for the first time.

Sharp


Secretly shuddering, I chuckled nervously back "that would probably be more of a problem for your sleep cycles, than for my puritanical modesty."

To my utter relief, the guard laughed then said "are you carrying anything sharp?"

"No" said I. "I am completely helpless. Is the TSA doing anything to protect me?"

"We have armed security men on the planes these days" said he, "but not on every plane."

I queried "So what is to protect me if some nut case decides to try to carve up like a roast?



Do I still have the right to defend myself?"

"Constitutionally, I suppose you might" said my guard "but my entire purpose here is to disarm you" he laughed.

"But what if we were ALL armed?" I mused "Wouldn"t dealing with the threat of a plane full of pissed yet happily armed Americans be a far better deterrent than assuring the world that we have all been disarmed?"


You idiot we all have swords!


"Probably." agreed the guard. "The Constitution of the United States says that we all have the right to bear arms - to defend ourselves."



"So why are you sitting up there, so happily depriving me of that right?" I queried.

"I suppose" said he "that it is because practically no one in the country knows how to defend themselves anymore. Americans have grown to trust others to do it for them."

Conversation over.

Reliance


Thankful for having my britches still firmly in place after this encounter, I waddled back to my favorite corner of this airport to think for a moment.

After awhile, I genuinely came to appreciate the one truly innovative idea our President has mentioned do date: That Americans should not be relying exclusively upon the armed forces to protect U.S; -That we all should be taking a much more active part in preserving our freedom!

Invaders


Indeed, after World War II, it was only as I pondered how, when asking the leaders of the Japanese Armed Forces why they did not invade our shores after Pearl Harbor, that the unusually rational, wonderful truth of Obama"s great idea became clear to me: The truth was that even an invading army was not willing to take on the bloody proposition of facing a fully armed, weapon savvy, American population.

In short, the Japanese were intelligently avoiding re-creating an American version of a house to house, city to city, and town to town, Revolutionary (or Vietnam!) War.

Ripening for Invasion?


So from messing with our gunpowder to taking away our screwdrivers, why is our government wanting to disarm U.S? Why are we not offering military-led training on hand-to-hand, and / or small arms training?

Indeed, I recall how, when I was about 12 years old, the Pilot of an American Airlines prop-job, upon seeing my frequent-flyer Dad and I climb the stairs to sit early on the plane, walked out of the cockpit to hand me a pen-knife bearing the company logo. It was the first knife I ever owned!

No Fear!


You see, back then most American men knew that the most mind-numbingly useful thing anyone could own was a knife. Yet today, because no one sees a knife outside of an Alfred-Hitchcock shower scene, many laws have been passed; Metal detectors are all over our schools.

Yet I, like many others, carried a sheath knife on my belt for much of my high school years I the Carolinas. --That was only 30 years ago!

Who Knew?


My, how things have changed!

Yet even more than ever, the world is still a very nasty place to live. Should we know how to defend ourselves? Celebrating our constructional-guaranteed rights?

I will leave it to you to decide who knew more about running a free country: Our ancestors, or our modern elected representatives. In fact, if Obama can make good on his utterance that we - each and all - should be learning how to defend our freedom ... be he a tax-and-spend socialist or not ... I for one would be willing to support him for re-election!

I love this country: Is anyone far-sighted enough to see how we MUST be ALLOWED to be fearless? Ever willing, ever-able to defend ourselves?



Related: Minuteman: Defending Self = Protecting Others?


[ add comment ] ( 17394 views )   |  permalink  |  related link

<<First <Back | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | Next> Last>>