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!


file_name="`basename $0`"


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 in the below,) all you need to do next is to call it. The script expects a pair of folders on its command-line:



file_name="`basename $0`.rpt"

./ $source $dest | tee $file_name

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



file_name="`basename $0`.rpt"

./ $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.


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:

for arg in "/my_folder1" "/my_folder2"
cp -r -u -v --preserve $arg "./"

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.


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.


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 ] ( 2104 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 ] ( 1908 views )   |  permalink  |  related link

<<First <Back | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | Next> Last>>