Saturday, 14 May 2011

Backup & Restore

Backup: It is an option in which we can store the data in any removal devices.
Restore: Restore is an option in which we can restore the data when some one has accidentally deleted the data.
Types of TAPES user for backup:
QIC: Quarter Inch catrage
DAT: Digital Analog Tape
DLT: Digital Linear Tape
SDLT: Silicon Digital Linear Tape

Types of backup:
1. File Backup
2. File System backup

1. File Backup:
We used to take a backup of files & directories in the system. then a different switches which are used to take file backup.
1. TAR
2. CPIO
types:
1. Absolute backup: It is used to take a backup of file and directories that can be restored to the same location.
2. Relative backup: It is used to take a backup of file and directories that can be restored to any other location.

1. TAR (TAPE Archive):
1. It supports both absolute and relative backups.
2. It doesn't support multiple tape, the backup can be taken to the single tape.
3. If any bad sectors are found in a tape the backup stops there itself. It doesn't move forward.

Syntax for TAR:
tar <options> <destination> <source>
ex: tar cvf /dev/rmt/0 /data

Options:
c- create or copy
v- verbose
f- files
t- tables
x- extract or restore
r- replace
u- update

check the backup:
# tar tvf /dev/rmt/0

extract backup:
# tar xvf /dev/rmt/0

1. Absolute backup:
1. mkdir /sun
2. cd /sun
3. touch s1 s2 s3 s4 s5
4. cd
taking the backup from root (/) of /sun is absolute backup
taking the backup from /sun of /sun is relative backup

Note: to take an absolute backup your present working directory that is other than the directory which your taking a backup.

to recover: same location
for backup: should be root (/)

2. Relative backup: should be present working directory only.
#pwd
/sun

ex: of absolute:
# tar cvf /dev/rmt/0 /sun/*
now data in two drive it stores in /sun, /dev/rmt/0
to check the backup:
# tar tvf /dev/rmt/0

now remove /sun:
# rm -r /sun
# ls
no /sun

now can you recover data?
yes, from /dev/rmt/0

to recover the data:
# tar xvf /dev/rmt/0

note: not giving any source but it save in /sun only because absolute.
# ls
(sun is there)

relative backup:
# mkdir /data
# cd /data
# pwd
/data
# touch d1 d2 d3 d4
# ls
d1 d2 d3 d4
# tar cvf /dev/rmt/0 .

check the backup:
# tar tvf /dev/rmt/0
# cd /mnt
# tar xvf /dev/rmt/0
now 3 copes /data, /dev/rmt/0, /mnt


CPIO: (Copy Input Output):
TAR: There is no Filter
o = It reads the files from system to output library
O= It is used to redirect the data to the required location. i.e. /dev/rmt/0
i = It reads the data from backup tapes to input libray
I = It reads the data from standard output instead of input libray
 ex: data transfer rate: 512 Bytes
B = it is a blocking factor which reads 5120 bytes instead of 512 bytes.

CPIO supports only relative backup:
Advantage of CPIO:
1. It supports multiple tapes
2. If any bad sector is found on the tape it will try to eliminates the bad sector.
ex:
# mkdir /jogi
# cd /jogi
# touch j1  j2 j3
# ls
j1 j2 j3
# pwd
/jogi
backup: (directory for relative should  in present working)
# ls | cpio -ocvf -O /dev/rmt/0

check the backup:
# cpio -itvf -I /dev/rmt/0

# mkdir /sita
# cd /sita

to restore the backup:
# cpio -icvf -I /dev/rmt/0

note: for backup  o,O
        for recover: i, I
Some discrete symbols for cpio:
 'O' replace with '>'
 'I'  replace with '<'

to take a backup & restore by using re discrete symbols:
 # mkdir /john
 # cd /john
 # touch l1 l2 l3
 # ls
  l1 l2 l3
  # pwd

# find .| cpio -ocB>/dev/rmt/0

now two copies create & /john

To recover the data:
# mkdir /david
 # cd /david
 # cpio -icvdB</dev/rmt/0         // d- directory
as of now we have taken whole files of directory

Interactive backup:
It is used to take a backup of a specified files in the directory

ex: # mkdir /ahmed
    # cd /ahmed
    # touch a1 a2 a4 a5 a3
    
now i want to take the backup of only two files:
# cpio -oB>/dev/rmt/0
 -- type here--
    a1
    a2
   ctrl+D

# mkdir /johny
# cd /johny

to recover (only two files recover now)

# cpio -iB</dev/rmt/0
# ls
a1 a2

assignment:
how to recover a single file from a tape drive, where the tape drive have 10 files?
to copy or back of limited files of 5
l1 l2 l3 l4 l5
# cpio -ocvf -O /dev/rmt/0
l1 
l2
ctrl+D

# cpio -iB -I /dev/rmt/0 l1
only l1 file extracted














No comments:

Post a Comment