Friday, November 21, 2008  
Google
Web pcquest.com

CIOL Network sites

Search by Issue | CD Search | Sitemap | Advanced Search

"Ad: Nortel data network solutions are 40% more energy efficient" "Ad:Discover Green Intelligence, make your business strong"


 
    Enterprise Solutions
    Hands On
    ITstrategy

    Developer

    Tech Forum

    Trends

    Shootout

    Reviews
    Editorials
    In Depth
    Technology
    Extraedge

    IT Careers

    Vertical Focus

Subscribe to Print magazine.


now!


Newsletter

 

Home > > Linux Hands On > Backups and Disaster Recovery


Backups and Disaster Recovery




Continued from Page 1

A short note about the backup devices. Linux, by default, has support for SCSI tapes. The device /dev/st0 indicates the first such tape drive attached to your system. If you’d use mirroring across disks, you’ll see devices like /dev/md0, /dev/md1, etc, which are logical devices that represent a file system that points to two physical disk partitions that are mirrored.

Now, let’s look at what utilities to use when you do not use mirroring. I’d advocate the use of cpio to copy files from one disk to another. One single command does all, elegantly. Here’s a typical command that you’d use to copy the directory structure under /export/users to /spare/backup/users

backup.daily
#!/bin/sh
# Dump thingie
# Do incremental backups either to tape that is already in the remote
# tape drive or onto a spare disk that is mounted locally; it is assumed that
# these archives will be written to tape later.
#
if [ ‘echo $#‘ -ne 1 ]; then
echo "Usage: $0 [disk] [tape]"
exit
fi
#
BASE=/usr/local/bin
now=‘date ‘+%b %d %T %Y’‘
nowfile=‘date ‘+%b%d%Y’| tr -d ‘\040*’‘
then=‘cat $BASE/date.last.dump‘
if [ ‘echo $1‘ = "disk" ]; then
DEVICE=/mnt/backups/$nowfile.tar.gz
echo "Backing up to "$DEVICE"; Check if the backup partition is mounted in /mnt"
echo "Enter to continue; ^C to abort"
# The mount check for the partition can be automated too; for the present,
# do it one at a time, abort and restart.
read x
else
DEVICE=root@dumpyard:/dev/st0
echo "Backing up to "$DEVICE"; Assuming tape is loaded"
read x
fi
#
HOME=/export/home
#
cd $HOME
#
FILES="*"
# Update FILES as required
#
/usr/sbin/tar -z -c -v \
-f $DEVICE \
-N "$then" \
-V "Dump from $then to $now" \
$FILES >/tmp/backup.log.$nowfile
echo $now > $BASE/date.last.dump

# cd /export/users; find . -name -depth | cpio -pldmuv /spare/backup/users/

You could similarly create a cpio archive by specifying a tape device instead of the destination directory.

A variation of the same using the (GNU) tar is

# cd /export/users; tar zcvf /dev/st0 * >/tmp/backup.log.DDMMYY

dd is typically used in conjuction with cpio or tar.

# cd /export/users; tar zcvf - * | dd of=/dev/st0

is equivalent to the earlier command. To backup on a remote system, use either of

# cd /export/users; tar zcvf backups@remote.host.name:/dev/st0 *

(Backup onto tape device attached to host remote.host.name on which userid "backups" has permissions to allow remote command execution from userid root on your machine.)


Page(s)   1   2   3   4   5   

End of the article

PC Problems? Get a solution in 24 hours. Ask Tech Expert

Related CIOL links   External links  

--None--

 

none



Read Previous Linux Hands On...

   




Untitled 1


Does your business have Green Intelligence


What is SDSIASWODB?


No.1 Linux platform for SAP Applications


Newsletter




Previous Stories

Remote Logins

MagicPoint

File Associations in Linux

Message boards

Discuss this and many other IT topics at the
CIOL message board



   
 

 
 

Magazine Subscription | RQS | Contact Us | Team PCQuest | Advertising - Print