Edi Yanto (何 萬 新)

Various Backup and Restore Scripts

Posted on: March 6, 2009


(1) mt

# mt -f /dev/rmt/0n status (to check status of backup device)

# mt -f /dev/rmt/0n eom (to move to the end of tape)

# mt -f /dev/rmt/0 rewind (to rewind)

# mt -f /dev/rmt/0n fsf [count] (to jump [count] files)

# mt -f /dev/rmt/0n bsf [count] (to forward [count] files)

# mt -f /dev/rmt/0n erase (to delete tape)

# mt -f /dev/rmt/0n offline (to eject)

(2) tar

# tar tvf /dev/rmt/0o   (to check the tape)

# tar xvf /dev/rmt/0   (to tar from tape to HD)

# tar cvf /dev/rmt/0 /etc/hosts   (to tar files and directory to tape)

/etc/host and ./inet/hosts are symbolic linked

# tar rvf /dev/rmt/0 group   (to replace at the end of tarfile)

# tar cvfb  –  20 files | rsh host dd of=/dev/rmt/0  obs=20b
(to backup to a drive in remote host)

# rsh -n host dd if=/dev/rmt/0 bs=20b |tar xvBfb – 20 files
(to backup to a drive in remote host)

(3) ufsdump

(3a) For single file system

# ufsdump 0ucf /dev/rmt/0n /dev/rdsk/c0t0d0s0   (for full dump)

(3b) ufsdump option

0      : full dump
1 – 9  : gradual backup based from /etc/dumpdate
u      : record at /etc/dumpdate
c      : Catridge, (for 1000BPI density and 126 blocking factor)
l      : Autoload of next tape when tape ends before dumping finished.
v      : verify
S      : calculate capacity.
f   dump_file     :  record file image to dump_file
w        : /etc/dumpdate¸ shows ufs system which is not dumped yet

# ufsdump 0Sf /dev/rmt/0 /dev/rdsk/c0t0d0s0
873689088

# ufsdump w
Dump these file systems:
/dev/rdsk/c0t0d0s0    (     /) Last dump: Level 0, Date Wed Apr 29 12:50
/dev/rdsk/c0t0d0s7    (/export/home) Last dump: Level 0, Date Sat May  2 12:57
/dev/rdsk/c0t1d0s0    (      ) Last dump: Level 0, Date Wed Apr 29 11:23

# cat dumpdates
/dev/rdsk/c0t0d0s0               0 Wed Apr 29 12:50:50 1998
/dev/rdsk/c0t0d0s7               0 Sat May  2 17:20:01 1998
/dev/rdsk/c0t1d0s0               0 Wed Apr 29 11:23:19 1998

(3c) For multiple file systems into one tape

# ufsdump 0ucf /dev/rmt/0n /dev/rdsk/c0t0d0s0;ufsdump 0ucf \
/dev/rmt/0n /dev/rdsk/c0t0d0s7

(4) ufsrestore

(4a) Restoring Entire File System

# mount /dev/dsk/c0t0d0s7 /export/home

# cd /export/home

# mt -f /dev/rmt/0n fsf 1  (to move to next point)

# ufsrestore rvf /dev/rmt/0n

(4b)   ineractive restore

# cd  /var/tmp

# ufsrestore ivf /dev/rmt/0

Verify volume and initialize maps

Media block size is 126

Dump   date: Mon May 11 14:33:16 1998

Dumped from: the epoch

Level 0 dump of /user on blue:/dev/dsk/c0t1d0s3

Label: none

Extract directories from tape

Initialize symbol table.

ufsrestore > ls
.:

ufsrestore > cd lost+found

ufsrestore > cd /

ufsrestore > add passwd lost+found

ufsrestore > verbose

verbose mode off

ufsrestore > verbose

verbose mode on

ufsrestore> delete lost+found

ufsrestore > ls
.:

ufsrestore > extract

Extract requested files

You have not read any volumes yet.

Unless you know which volume your file(s) are on you should start

with the last volume and work towards the first.

Specify next volume #: 1

extract file ./passwd

Add links

Set directory mode, owner, and times.

set owner/mode for ‘.’? [yn] n

ufsrestore > quit

(4c) To restore files

# ufsrestore xvf /dev/rmt/0 ./etc/passwd

(4d) To display the content of the tape

# ufsrestore tvf /dev/rmt/0

(5) cpio commands

# find . -print | cpio -ovcB > /dev/rmt/0
(to copy current directory to tape)
.
upgrade
upgrade/Agree.ps
upgrade/Announcement.ps
upgrade/Program.ps
upgrade/Refund.ps
upgrade/URCFORM.ps
array
array/DECptscII
array/DECptscII/pkgmap
array/DECptscII/pkginfo
array/DECptscII/root
array/DECptscII/root/kernel
array/DECptscII/root/kernel/drv
array/DECptscII/root/kernel/drv/classes
array/DECptscII/root/kernel/drv/ptscII.52
array/DECptscII/root/kernel/drv/ptscII.53
array/DECptscII/install
array/DECptscII/install/copyright
array/DECptscII/install/postinstall
array/DECptscII/install/preremove
array/DECstgwks
array/DECstgwks/pkgmap
array/DECstgwks/pkginfo
array/DECstgwks/root
array/DECstgwks/root/$TRANSDIR
array/DECstgwks/root/$TRANSDIR/sd.conf
array/DECstgwks/root/$TRANSDIR/trans.Z
array/DECstgwks/root/$TRANSDIR/trans.conf

# cpio -ivcB array/DECstgwks/install/foobar < /dev/rmt/0
(to extract foobar from tape)
array/DECstgwks/install/space
8550 blocks

# find . -mtime -7 -print | cpio -ovcB > /dev/rmt/0n
(to copy files which was modified within the last seven days)
.
upgrade
upgrade/Agree.ps
upgrade/Announcement.ps
upgrade/Program.ps
upgrade/Refund.ps

# find . -name ‘file*’ -print | cpio -ovcB > file.list

# cpio -ivt < file.list

(6) Backup script sample

#!/bin/csh

set verbose

set day = `date +%y%m%d`

mt -f /dev/rmt/0n rew

ufsdump 0uf /dev/rmt/0bn /

ufsdump 0uf /dev/rmt/0bn /usr

ufsdump 0uf /dev/rmt/0bn /var

ufsdump 0uf /dev/rmt/0bn /export/home

ufsdump 0uf /dev/rmt/0bn /opt

echo “now test the backups.”

mt -f /dev/rmt/0n rew;ufsrestore tfs /dev/rmt/0n 1 > \
/export/home/bert/dumpfile1.${day}

mt -f /dev/rmt/0n rew;ufsrestore tfs /dev/rmt/0n 2 > \
/export/home/bert/dumpfile2.${day}

mt -f /dev/rmt/0n rew;ufsrestore tfs /dev/rmt/0n 3 > \
/export/home/bert/dumpfile3.${day}

(7) Sun O/S backup parameter

High density Fujitsu/Xylogics 1/2″ tape

# dump 0uf /dev/rmt8 /dev/rxy0

600′ QIC-24 9 track 1/4″ cartridge tape

# dump 0ucf /dev/nrst8 /dev/rds0h

QIC-150 18 track 1/4″ catridge tape:

# dump 0ucsf 1500 /dev/rst0 /dev/rsd0h

Exabyte 8mm catridge tape:

# dump 0usf 145000 /dev/rst0 /dev/rid001h

2 Responses to "Various Backup and Restore Scripts"

Ini backup ke tape ya ?
Bagaimana deteksi tape device di linux

Like

iya tu bakcup ke tape di Sun, mksd u deteksi kyk apa? cek statusnya? ada tape yg aktif ato tidak gt? di Linux gue sendiri sich blm coba..

Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 1,368 other followers


Edi Yanto
Oracle Applications Technical Consultant
View Edi Yanto's profile on LinkedIn

My Certifications






Follow me on Twitter

Archives

March 2009
M T W T F S S
« Feb   Apr »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Visitors

Categories

Blog Stats

  • 140,585 hits

Users Online

web counter

Pages

%d bloggers like this: