≡ Menu

Linux Shell Script To Backup To Tape Drive

# A simple shell script to backup dirs to tape drive.
# -------------------------------------------------------------------------
# Copyright (c) 2005 nixCraft project 
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# -------------------------------------------------------------------------
# What to backup.
SOURCE_DIRS="/data /home /etc /root /www"
# Where to backup to.
# log message
$LOGGER "Backing $SOURCE_DIRS to $TAPE @ $(date)"
# Rewind the tape
$MT -f $TAPE rewind
# Backup the files
# Rewind and eject the tape
$MT -f $TAPE rewoffl
# log message
$LOGGER "Backup finished @ $(date)"

Comments on this entry are closed.

  • What is the easiest possible solution to transfer 1TB of audio content from one datacenter to the other. The date cant be transferred physically, It can only be transferred through connection.

  • somed000d

    You probably have this done by now, but…
    It depends on the platform that you are on. But if you don’t have a physical way to transfer the data then I hope you have a fat backbone.

    I find that the easiest way is to use either scp, or rsync on any Linux or Unix OS. Both of these the SSH protocol to encrypt the data as it’s being transferred. I prefer rsync over scp just because it’s made for syncing up directories and the like, while scp is more like FTP, but through SSH.

    Here’s how I would normally run rsync to sync two directories and make them exactly the same:

    rsync -rlt –progress –update –delete /path/to/local/directory/ user@host:/path/to/remote/directory/ (the trailing slashes do make a difference).

    Anyway, that’s just an opinion from a nobody.

  • Nice, Thank You

  • how to backup automatically after the file created 6 month ago, without crontab?!

  • tdmurthy

    How to take incremental & differential backup in linux with crontab?

  • regan

    hi how can i view the logs using your script here? thanks

  • regan

    btw, is this also applicable to solaris 10?thanks

  • Antti M.

    You should not use gzip in backups single bit error and the entire stream is losts. Bzip2 is different and using pbzip2 -1 -c you can get quite speedy.