7.6 Backing up files (tar, cpio)
Device Files
UNIX में सब कुछ files है और यदि कोई file नहीं है तो वह process है |
अतः devices को भी files की तरह treat किया जाता है |
इस प्रकार device पर read/write करना file पर read/write करने जैसा ही है | इसके लिए आवश्यक functions (device driver) kernel का part होते है |
सभी
device files को /dev
directory में रखा जाता है |
#ls –l /dev To list all the device files (-l : long listing)
Device
files दो प्रकार की हो सकती है – block device (b) and character device (c)
Device
files की long-listing में पांचवां field दो संख्याओं का pair (युग्म) है | first
number को major number तथा second number को minor number कहा जाता है |
•Note
– Device file में कोई data नहीं होता है |
cpio – a backup program
cpio (copy input-output) एक backup program है | यह files को
computer disk से backup device पर तथा backup device से computer disk पर copy करता है |
cpio -o
-o : files का backup (archive) create करने के लिए | (output)
–i : archive से पुनः files को restore करने के लिए | (input)
# ls | cpio -ov > /dev/fd0
# cpio -o > /dev/fd0 < flist
यहाँ ls command files की list को standard output पर send करेगा जिसे cpio standard input पर receive करेगा | option –o का अर्थ है की cpio archive create करेगा | cpio archive को standard output पर Write करता है जिसे device file को redirect किया गया है |
-v : verbose
cpio -i
#cpio -iv < /dev/fd0
यह command device file /dev/fd0 से सम्पूर्ण archive को restore (backup device to computer disk) करने के लिए है |
#cpio -i “*.sh” < /dev/fd0
यह command केवल selected files को (all files with extension .sh) को archive में से restore करने के लिए है |
Note – यदि files को absolute pathname के साथ archive किया गया है तो वे वहीँ पर restore होगी | यदि files को relative pathname के साथ archive किया गया है तो उन्हें कहीं भी restore किया जा सकता है |