Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 19 File System Backup. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. Objectives To describe how files and directories can be archived.

Similar presentations


Presentation on theme: "Chapter 19 File System Backup. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. Objectives To describe how files and directories can be archived."— Presentation transcript:

1 Chapter 19 File System Backup

2 Copyright © 2005 Pearson Addison-Wesley. All rights reserved. Objectives To describe how files and directories can be archived and restored in UNIX To explain recovery of a subset of archived files To cover the commands and primitives |, >,cd, compress, file, ls, pwd, tar, uncompress

3 Copyright © 2005 Pearson Addison-Wesley. All rights reserved. Introduction System administrators normally use a tape as the storage medium for archiving complete file system structures as backups Making an archive makes it convenient to deal with a single file instead of a complete directory hierarchy Files can be archived using cpio, dump, and tar

4 Copyright © 2005 Pearson Addison-Wesley. All rights reserved. Archiving and Restoring Files via tar The tar utility was originally designed to save the file systems on tape as a backup Also commonly used now to pack directory hierarchy as on ordinary disk file

5 Copyright © 2005 Pearson Addison-Wesley. All rights reserved. Archiving Files with tar

6 Copyright © 2005 Pearson Addison-Wesley. All rights reserved. Archiving Files with tar

7 Copyright © 2005 Pearson Addison-Wesley. All rights reserved. Archiving Files with tar

8 Copyright © 2005 Pearson Addison-Wesley. All rights reserved. Archiving Files with tar

9 Copyright © 2005 Pearson Addison-Wesley. All rights reserved. Archiving Files with tar

10 Copyright © 2005 Pearson Addison-Wesley. All rights reserved. Archiving Files with tar $ cd ~/unixbook $ tar cvf unixbook.tar. a./ 0K tar:./unixbook.tar same as archive file a./final/ 0K a./final/ch1.doc 41K a./final/ch2.doc 53K a./final/ch3.doc 140K... a./current/ 0K a./current/ch07.doc 200K... a./current/ch12.doc 340K $ ls -l drwx------ 2 sarwar 512 Jul 22 13:21 current drwx------ 2 sarwar 512 Jul 22 13:21 final -rw------- 1 sarwar 2064896 Jul 22 13:47 unixbook.tar $ file unixbook.tar unixbook.tar: USTAR tar archive $

11 Copyright © 2005 Pearson Addison-Wesley. All rights reserved. Restoring Archived Files $ cp unixbook.tar ~/backups $ cd ~/backups $ tar xvf unixbook.tar x., 0 bytes, 0 tape blocks x./final, 0 bytes, 0 tape blocks x./final/ch1.doc, 41984 bytes, 82 tape blocks x./final/ch2.doc, 54272 bytes, 106 tape blocks... x./current/ch10.doc, 121344 bytes, 237 tape blocks x./current/ch11.doc, 152576 bytes, 298 tape blocks x./current/ch12.doc, 347648 bytes, 679 tape blocks $ ls -l drwx------ 2 sarwar 512 Jul 22 13:21 current drwx------ 2 sarwar 512 Jul 22 13:21 final -rw------- 1 sarwar 2064896 Jul 22 13:47 unixbook.tar $

12 Copyright © 2005 Pearson Addison-Wesley. All rights reserved. Restoring Archived Files $ tar -tvf unixbook.tar drwx------ 121/152 0 Jul 22 13:47 1999./ drwx------ 121/152 0 Jul 22 13:21 1999./final/ -rw------- 121/152 41984 Jul 19 13:06 1999./final/ch1.doc... drwx------ 121/152 0 Jul 22 13:21 1999./current/ -rw------- 121/152 204288 Jul 19 13:06 1999./current/ch07.doc... -rw------- 121/152 347648 Jul 19 13:06 1999./current/ch12.doc $ tar -tvf unixbook.tar | grep ch10.doc -rw------- 121/152 121344 Jul 19 13:06 1999./current/ch10.doc $ cd ~/unixbook $ tar -xvf ~/backups/unixbook.tar current/ch10.doc current/ch10.doc $

13 Copyright © 2005 Pearson Addison-Wesley. All rights reserved. Restoring Archived Files

14 Copyright © 2005 Pearson Addison-Wesley. All rights reserved. Copying Directory Hierarchies Can use the tar command to copy one directory to another directory Can also use the cp –r command to do so, but the disadvantage is that the file access permissions and file modification times are not preserved Access permissions of the copied files and directories are determined by the value of umask and the modification time is set to current time More commonly tar is used to archive the source directory, create the destination directory, and untar (unpack) the archived directory in this latter directory Advantages of using command line: –Both cd and tar commands are available on all UNIX systems –Copied files have the access permissions and file modification times for source file

15 Copyright © 2005 Pearson Addison-Wesley. All rights reserved. Copying Directory Hierarchies $ (cd ~/unixbook/examples; tar -cvf -.) | (cd~/unixbook/examples.bak; tar -xvf -) a./ 0K a./Bshell/Domain, 14 bytes, 1 tape blocks a./Bshell/IP, 18 bytes, 1 tape blocks... a./Bshell/dir1, 0 bytes, 0 tape blocks a./Bshell/copy, 2222 bytes, 5 tape blocks x., 0 bytes, 0 tape blocks x./Bshell/Domain, 14 bytes, 1 tape blocks x./Bshell/IP, 18 bytes, 1 tape blocks... x./Bshell/dir1, 0 bytes, 0 tape blocks x./Bshell/copy, 2222 bytes, 5 tape blocks $

16 Copyright © 2005 Pearson Addison-Wesley. All rights reserved. Software Distribution in the tar Format Tar commands used to distribute software because it results in a single file that the customer needs to copy and it saves disk space The –z option of the GNU tar can be used to generate the compressed version of the tar archive and to restore the compressed version of the tar archive

17 Copyright © 2005 Pearson Addison-Wesley. All rights reserved. Software Distribution in the tar Format $ uncompress tcsh-6.06.tar.Z $ tar xvf tcsh-6.06.tar... [command output] $ $ tar -zcf ~/unixbook/backups/ub.tar.gz. $ tar -zxvf ~/unixbook/backups/ub.tar.gz [ command output ] $


Download ppt "Chapter 19 File System Backup. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. Objectives To describe how files and directories can be archived."

Similar presentations


Ads by Google