Presentation is loading. Please wait.

Presentation is loading. Please wait.

tar: The tape archive program _______________________ Amber Jain IC-2K7-05 _______________________.

Similar presentations


Presentation on theme: "tar: The tape archive program _______________________ Amber Jain IC-2K7-05 _______________________."— Presentation transcript:

1

2 tar: The tape archive program _______________________ Amber Jain IC-2K7-05 ithinkminus@gmail.com _______________________

3 Introduction 'tar' is used to create and manipulate files archives which are actually collections of many other files. 'tar' program provides users with an organized and systematic method for controlling a large amount of data. tar is a versatile command with certain exclusive features not found in cpio.

4 What are 'Archives' ? An archive is a single file which contains the contents of many files, while still identifying the names of the files, their owner(s), and so forth. In addition, archives record access permissions, user and group, size in bytes, and last modification time.

5 What tar does ? The tar program provides the ability to create tar archives, as well as various other kinds of manipulation. For example, you can use tar on previously created archives to extract files, to store additional files, or to update or list files which were already stored. Initially, tar archives were used to store files conveniently on magnetic tape. The name ‘tar’ comes from this use; it stands for tape archiver.

6 Why do we need tar ? Storage: Often, tar archives are used to store related files for convenient file transfer over a network. Backup: Because the archive created by tar is capable of preserving file information and directory structure, tar is commonly used for performing full and incremental backups of disks. Transportation: You can create an archive on one system, transfer it to another system, and extract the contents there. This allows you to transport a group of files from one system to another.

7 'tar' file naming conventions Conventionally, tar archives are given names ending with ‘.tar’ (although this is not necessary for tar to operate properly)

8 Exclusive features tar doesn't uses standard input to obtain its file list. Tar accepts file and directory names as arguments. For example: $ tar -cvf /dev/fd0 /home/user/SQL/*.sql Filename passed as command line arguements

9 Exclusive features (Cont'd) tar copies one or more entire directory trees (i.e. it operates recursively).

10 Exclusive features (Cont'd) tar can create several versions of same file in a single archive. tar can append to an archive without overwriting the entire archive.

11 Summary: tar options

12 Backing up files The command to backup all SQL scripts with their absolute pathnames to the floppy diskette (/dev/fd0): $ tar -cvf /dev/fd0 /home/user/SQL/*.sql a /home/user/SQL/invoice.sql 1 tape blocks a /home/user/SQL/duplicate.sql 1 tape blocks a /home/user/SQL/bill.sql 1 tape blocks a /home/user/SQL/customer.sql 10 tape blocks 'a' indicates that the file is appended

13 Specifying block sizes The command will execute faster if used with a block size of 18 (i.e. 18 * 512 bytes): $ tar -cvfb /dev/fd0 18 *.sql Note: Never use tar and cpio with their default block sizes. Choose as high a value as the system permits. Higher block sizes speed up I/O operations.

14 Backing up hidden files The current directory can be backed up with or without the hidden files: $ tar -cvfb /dev/fd0 18 * #Doesn't back up hidden files $ tar -cvfb /dev/fd0 18. #Backs up hidden files

15 Disk Space tar in some older unixes (e.g. SCO UNIX: a very old and obsolete version of unix) accomodates as much files as possible and then quits the program without warning. Most linuxes (and many modern Unixes), however, issues this warning: tar: Cannot write to /dev/fd0: No space left on drive

16 Multi-volume backup In SCO UNIX, you can use -k followed by volume size in bytes: $ tar -cvfkb /dev/fd0 1440 18 index Volume ends at 1439K, blocking factor=18 tar: large file index needs two extents. tar: current device seek position = 0K +++ a index 1439K [extent #1 of 2] After the first volume is full, tar prompts for a new volume: tar: please insert new volume, then press return

17 Multi-volume backup (Cont'd) Linux identifies the volume size from the device name itself. It uses a different option -M: $ tar -cvf /dev/fd0 -M *

18 Restoring files Files are restored with -x (extract) option: $ tar -xvfb /dev/fd0 18 x /home/user/SQL/invoice.sql, 169 bytes, 1 tape blocks x /home/user/SQL/duplicate.sql,456 bytes, 1 tape blocks x /home/user/SQL/bill.sql,237 bytes, 1 tape blocks x /home/user/SQL/customer.sql,4855 bytes, 10 tape blocks x indicates that files are being restored

19 Displaying the archive -t option displays the contents of the device without restoring the files. When used with -v option, they are displayed in long format: $ tar -tvf /dev/fd0 rwxr-xr-x203/50 472 Jun 4 09:35 1991./file1.sh rwxr-xr-x203/50 554 Jun 4 09:52 1991./file2.sh

20 Appending to the archive A file can be added to the archive with the -u option: $ tar -uf /dev/fd0./func.sh

21 Interactive copying and restoration When tar is used with the -w option, it prints the name of the file and prompts for the action to be taken (y or n): $ tar -xvwf /dev/fd0./func.sh x rwxr-xr-x203/50 2299 Jun 4 13:59 1991./func.sh : y x rwxr-xr-x203/50 2455 Jun 13 14:13 1991./func.sh : n When there are several versions of a single file, it is better to include the verbose option so that the modification times (or the size) can be seen.

22 Any queries?


Download ppt "tar: The tape archive program _______________________ Amber Jain IC-2K7-05 _______________________."

Similar presentations


Ads by Google