There are three different time specifications to every
file on a UNIX system. While many backup utilities will
maintain the current creation time (ctime), and some even track the
file's modification time (mtime), BRU also keeps track of the file's
access time (atime).
The importance in keeping track of a file's atime is when it comes
time to clean up old and unused files. On an average system, 40% to 60%
of all user files haven't been touched by the user that created them in
more than 120 days. These files clutter up your system, wasting disk
space and inodes needlessly.
But, if your backup utility doesn't reset the atime of the files as it
backs them up, the atime gets updated by the system to the time that the
backup utility touches the file for read (a type of access). This means
that files will have an atime that is as current as your last backup.
BRU, on the other hand, checks each file's atime before it backs it up and
resets it after it is backed up. Also, in the event of a restore, BRU
will reset the restored file's atime to what it was when BRU backed it up.
This script allows you to see the three different time stamps for a given
file.
:
#
# showtime Show the times of a file
#
F=$1
if [ $# -gt 2 ]
then
echo "ERROR: more than one file specified"
exit 1
fi
if [ "$F" = "" ]
then
echo "ERROR: No file specified"
exit 1
fi
MTIME=`ls -l $F` # modification time
CTIME=`ls -lc $F` # inode change time
ATIME=`ls -lu $F` # access time
echo "$MTIME (MTIME)\n$CTIME (CTIME)\n$ATIME (ATIME)"
With this is mind, we must ask why some companies require you to spend large
sums of cash to purchase a disk grooming and migration tool. Here's a standard
shell script that will check for files that haven't been accessed in a given
period, write them to two (or more) tapes and then erase them from your
system.
#!/bin/sh
#######################################
#
# Shell script to perform file migration based on access time
#
# Copyright 1995, Enhanced Software Technologies, Inc.
#
# Permission is granted to use or modify
#
# EST Makes no warranties as to the suitability of this software. It
# is the responsibility of the user to determine the usefulness of
# this information.
#
# EST and Tim Jones are not responsible for any damages that occur
# because of the use or misuse of this script
#
#######################################
# Variables used below
AGE=120 # How STALE should a file be (in days)
DEVICE=/dev/rmt99 # edit for your device!
DATE=`date +%m-%d-%y %H:%M`
LABEL="Migration Backup ${DATE} - DO NOT OVERWRITE!"
#
# Build a list of file that haven't been touched in AGE days
#
Build_List() {
echo "Building list of files for migration ... be patient"
find /home -atime +${AGE} -print >> /tmp/migrate_list
echo "File list complete. Stored as /tmp/migrate_list."
}
#
# Backup the files and run a bit comparison verification
#
Backup_Files () {
echo "Backing up files to tape ..."
bru -cvvL ${LABEL} -a -G -f${DEVICE} - </tmp/migrate_list
bru -dddvv -f${DEVICE}
result=$?
if [ $result -ne 0 ]
then
echo "Some files have changed since the backup occured."
echo "This invalidates the list of files being processed for migration."
echo
echo "Aborting migration operation."
exit 1
fi
}
#
# Ask the operator for permission to delete the files and remove them
# if permitted.
#
Remove_Files () {
echo "You are about to delete the files that were previously backed up
echo -n "permanently! Are you sure you wish to continue (y/N)? "
read continue
case ${continue} in
n|N)
echo "Aborting the file deletion!"
exit 1
;;
y|Y)
echo "Deleting files ..."
cat /tmp/migrate_list | rm -rf
echo "Deletion Complete!"
exit 0
;;
*)
echo "Aborting the file deletion!"
exit 1
;;
esac
}
######################################
#
# Main Operation Begins here!
#
# You may add additional Backup_Files calls below if you wish to create
# more than two copies of the files.
#
######################################
Build_List
Backup_Files
echo -n "The first tape copy is complete. Insert tape 2 and press ENTER"
read answer
Backup_Files
echo -n "The second tape copy is complete. Be sure to lock these tapes away!"
Remove_Files
Keep in mind that this script is designed as an EXAMPLE. It may not be
directly functional on your system. Also, it depends on the validity of
the atime information of your files. If you aren't using BRU's -a option
in your backups, your files will only be as stale as your last backup!