Developing a Simple Backup Strategy
The importance of good backups can never be overstated. Most businesses live or die by the data that they have created. A major priority of every administrator should be a excellent system for consistent backups. This system must be automated and all of those responsible have to be trained in backup verification and restoration.
There are a number of options for performing backups.
One popular media for backups are CD or DVDs whether they are RW or just R. This media uses a laser with a photochemical process to write the data. The shelf life is typically longer than magnetic however there are a number of variables which change the lifetime. CD and DVD are typically cheap around $.15 for CDs and $.25 for DVDs. If you choose this media for backup it is important that you use the best media you can afford. Cheap media is not dependable and does not have the lifetime of high quality media. Mark your media with water soluble markers as permanent markers will have a tendency to damage the media. The media should be stored between 42-68 degrees F with 30-50% humidity for longest life. The biggest drawback to using this media is the limit in space.
The advantages of USB are that it is easy to setup. USB media is limited by the number of writes that can be performed to the media so a time span for all USB media should be established. The two biggest drawbacks to USB are speed and limited drive size.
USB Connection with Hard Drives
Now it is possible to purchase RAID arrays set up in an external device. These provide an east excellent backup. Plug them in and develop your strategy.
Tape drives have been an important source for backups for years. However, because of the higher cost for tapes, management of tapes and the lifespan of tapes, tape drives are not as popular as they once were.
The fastest, most inexpensive and very reliable are hard drive backups. These are the easiest to manage and can be automated for long periods of time.
Because hard drives are the most readily available media for backups this section will cover backing up to hard drives only.
The tar program is on all Linux systems and provides a way to create a backup of a directory quickly. The format for tar is:
tar options destination source
It is easy to get the destination and source confused so double check it. If the user mary wanted to back up her home directory to a backup partition called /bk this would be the command:
tar cvf /bk/mary_bk.tar /home/mary
Notice the options are:
c create an archive
v verbose and list all the activity
f place the archive in a file
Now if there was a system crash and mary needed to retrieve that tar file and expand it here is the command to do that:
tar xvf /bk/mary_bk.tar -C /
The options are:
x extract the files
f read from the file
Notice that if mary lost her directory the whole thing could be restored by indicating where to restore it and that is why the / is important because it would recreate /home/mary from the / directory.
In the home directory for mike there is a Data folder which contains important information. /home/mike/Data The user mike (not root) moves into the /home/mike directory and does:
tar cvf Data.tar /home/mike/Data.
The Data directory is removed so it looks like this now:
There is no Data directory. Now mike from the location of /home/mike does:
tar xvf Data.tar
However, no Data file is created.
But…when mike does:
tar xvf Data.tar -C /
The directory Data and contents are now restored.
-C, –directory DIR change to directory DIR
So in this example you are changing to the / directory before expanding the tar file.
Search the Contents of a tar File
If you need to find a file to backup and it may be located in a tar file you can use grep to locate it.
tar -tvf mytarfile.tar | grep myfile
Simple tar Script
This script will backup the /home directory and create a tar file with a timestamp. This will give you the ability to backup as often as needed. With the low cost of hard drives this could be a usable option.
# Timestamped Back Up
tar cvf /bk/home_$TIMESTAMP.tar /home