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 करता है |

यह command group of files को archive में बदलता है | 

Backup device एक magnetic या cartridge tape, floppy diskette, या disk file हो सकती है |

यह backup की जाने वाली files की list को standard input से receive करता है तथा इन files को content के साथ header add करने के बाद standard output पर write करता है | जिसे किसी file या device को redirect किया जा सकता है |

इस प्रकार cpio command को redirection तथा piping के साथ use कर सकते है | 

cpio -o 


cpio command द्वारा दो options का प्रयोग किया जाता है -

-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 -i  command का प्रयोग सभी या कुछ files को archive से restore करने के लिए होता है |

#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 किया जा सकता है |


cpio -it

-t option (table of contents) archive के contents को show करता है बिना restore किये |

#cpio -itv  < /dev/fd0

इसका output ls command की तरह ही होता है |


Last modified: Monday, 30 March 2020, 10:01 PM