OnWorks Linux and Windows Online WorkStations

Logo

Free Hosting Online for WorkStations

< Previous | Contents | Next >

2.2. Tape Drives


A tape drive attached to the server can be used instead of an NFS share. Using a tape drive simplifies archive rotation, and makes taking the media off-site easier as well.


When using a tape drive, the filename portions of the script aren't needed because the data is sent directly to the tape device. Some commands to manipulate the tape are needed. This is accomplished using mt, a magnetic tape control utility part of the cpio package.


Here is the shell script modified to use a tape drive:


#!/bin/bash

####################################

#

# Backup to tape drive script.

#

####################################


# What to backup.

backup_files="/home /var/spool/mail /etc /root /boot /opt"


# Where to backup to. dest="/dev/st0"


# Print start status message.

echo "Backing up $backup_files to $dest" date

echo


# Make sure the tape is rewound. mt -f $dest rewind


# Backup the files using tar. tar czf $dest $backup_files


# Rewind and eject the tape. mt -f $dest rewoffl


# Print end status message. echo

echo "Backup finished" date


image

The default device name for a SCSI tape drive is /dev/st0. Use the appropriate device path for your system.


Restoring from a tape drive is basically the same as restoring from a file. Simply rewind the tape and use the device path instead of a file path. For example to restore the /etc/hosts file to /tmp/etc/hosts:


mt -f /dev/st0 rewind

tar -xzf /dev/st0 -C /tmp etc/hosts


Top OS Cloud Computing at OnWorks: