Sunday, 15 May 2011

File System Backup

File System Backup:
- It is used to take a backup of the file system
- File system backup can be taken in two modes
  1. mounted state
  2. unmounted state

- command used for backup & restore
  1. ufsdump: It is used to take a backup of File System
  2. ufsrestore: It is used to recover the backup.

types of backups
 1. full backup: It will take a backup of all the files & directories
 2. incremental backup: it is used to take a backup of user created (or) newly modified file.

Note: To identify the backups we use numbers from 0-9
where '0' represents full backup
and '1-9' represents incremental backup

1. to take a backup of the File System which is in unmounted state:
step1: create a File System, Format it, and mount it, and write some data into the mount point
s4 having - 100mb
 # newfs /dev/rdsk/c0t0d0s4
 # mkdir /jumbo
 # mount /dev/dsk/c0t0d0s4 /jumbo
 # df -h
 # cd /jumbo
 # touch j1 j2 j3 j4 j5 j6
 # ls

to take a backup:
1. unmount the FileSystem:
 # umount /jumbo

2. take a backup:
 # ufsdump Ouf /dev/rmt/0  /dev/rdsk/c0t0d0s4
 //dump is done, level 0 dumped on wed apr 7:40 pm

Note: while taking a backup in option we can use 'u' option for update a file called /etc/dumpdates
# cat /etc/dumpdates
/dev/rdsk/c0t0d0s4   0 wed apr13 7:40pm

after this what ever file you updated comes under I.B (suppose if you delete s4, we can recover from /dev/rmt/0

to verify the backup & recovery format the slice:
# newfs /dev/rdsk/c0t0d0s4
# mount /dev/dsk/c0t0d0s4 /jumbo
# df -h
(s4 slice visible now)
# cd /jumbo
# ls
(no file bcoz we format it)
to recover: ufs restore:
to view files (check)
# ufsrestore tvf  /dev/rmt/0

to restore:
# ufsrestore rvf  /dev/rmt/0
# ls
# pwd
/jumbo

note: backup mean Filesystem should be unmounted


Back up of a File System in mounted state:
task:
-if suppose my boss said, it should be mounted only  /jumbo and i want back up & don't want any updates.
ans: fssnap                    // snap shot
- user can't accessible until snap shot.

Back up of a File System in mounted state:
- To take a backup of a File System in mounted state the option used is 'snap shot'
- while taking a 'snap shot' all the users will face a 'pause mode'. i.e they can view the File System, but they can't update the data to the File System.
- To create a File System, Format it, mount it & write the data into the mount point.

# Format                // take slice s6, 100m size
# newfs /dev/rdsk/c0t0d0s6
# mkdir /joy
# mount /dev/dsk/c0t0d0s6 /joy
# cd /joy
# touch j1 j2 j3 j4 j5
# ls
# df -h
  s6   (mounted state)

To create a snap shot:
# fssnap -F ufs -o bs=/var/tmp  /joy           // F- file

/dev/fssnap/0 : snap shot is a image of slice only ( it's not a backup, it is only a image, whatever file in s6 that will be in snap shot)

to verify a snapshot:
# mkdir /toy
# mount -F ufs -o -ro /dev/fssnap/0 /toy
# df -h
/s6   -   /joy
/dev/fssnap/0  -  /toy
# cd /joy
# ls
# cd /toy
# ls

//both have same data in joy & toy, so successfully taken of snap shot

to take a backup of a snapshot:
#  umount /toy

backup:
# ufsdump 0uf /dev/rmt/0 /dev/fssnap/0

till now 3 copies done
1. s6
2. /dev/fssnap/0
3. /dev/rmt/0

verify:
# cat /etc/dumpdates

to verify the backup & recover:
# fssnap -i
0  /joy

to date the snapshot:
# fssnap -d /joy
// deleted snapshot 0

# fssnap -i
//no snap shots

# umount /joy
# newfs /dev/rdsk/c0t0d0s6
// data lost

# mount /dev/dsk/c0t0d0s6 /joy
# cd /joy
# ls
// nothing, bcoz its formated

to recover the data:
# ufsrestore rvf /dev/rmt/0

check:
# df -h
# cd /joy
# ls
(yes, all recovered)

Note: when we recover the data by using 'ufsrestore' bydefault we are setting one directory
i.e. restorsymtable.
# cat

No comments:

Post a Comment