Zurück

Simple Shell Script to backup your Files


Overview

A backup strategy is more complex than creating a redundant copy of disk storage and considering the strategy a success. A successful backup strategy must detail how the backup media are rotated, how the media are archived, how the system will be recovered, and what the backup software will do to create the backup. Although all parts of the backup strategy are equally important, this tip will focus on the backup script and will detail a flexible backup script that uses built-in Solaris software tools which create a reliable local backup of a Solaris machine.

Introduction

The backup script will accomplish the following goals:

  • Create a backup archive that is as easy to restore a single file as it is to restore an entire file system.
  • The backup script will run autonomously. The only human intervention will be to swap media and review output.
  • The filesystems or directories to backup can be specified in the script. Using automounter you can even specify remote filesystems.
  • The script will create a detailed log of the backup.
  • The script will send an abbreviated email summary of the backup to the administrator.
  • After a successful backup, the script will verify to some extent the contents of the backup media.
  • The backup script will be able to run on any Solaris 2.6 or greater machine without modification.

Tools used

We use the well known utilities TAR, GZIP and DD, because they are available on any Unix system. They are very well tested and simple to use. In case of an emergency it is important to have a simple way to restore, independent of complex tools and incompatible software releases.

Magnetic Tape Control

The utility MT sends commands to a tape drive. Many of these commands are familiar, but some are not. The script will use these mt commands.

  • rewind – rewind the tape
  • rewoffl – rewind the tape and eject it (go offline)
  • eom – space to end of recorded media on tape
  • weof – write count EOF marks at current position on tape
  • status – display current status of tape

Script

Click here for the Shell Script