Create TAR archive (without compression)
tar -cvf myarchive.tar mydirectoryCreate TAR archive with compression (Gzip) archive
tar -czvf myarchive.tgz mydirectory
Note :-tgz is the same thing as .tar.gz
Testing / viewing your archive
tar -tvf myarchive.tartar -tzvf myarchive.tgz
Here we used the – t opton
-t, –list list the contents of an archive
Extracting TAR archive
Extract tar archive
tar -xvf mystuff.tar
Extract tar gz (Gzip) archive
tar -xzvf mystuff.tgz
Extract tar archive specific folder or file from archive
tar -xvf file.tar foo.txt tar -xzvf file.tar.gz foo.txt tar -xjvf file.tar.bz2 foo.txt
Example:-
tar -xvf [tarfilename.tar] [file name of the specified file form archive]
tar -xvf MyBackup.tar u01/backup/Misc/scripts/rman_scn_num.sh
tar -xvf MyBackup.tar u01/backup/Misc/scripts/rman_scn_num.sh
Extract tar archive to specified directory
Example:-
tar -xvf myarchive.tar -C /desired/path
tar -xvzf filename.tar.gz -C /desired/path
Extract TAR archive from remote box
Examples
cd /u01
ssh root@192.168.100.99 "cat /u01/axigen.tar" | tar xvf -
Note :- above example will take remote host tar file exact to local PC u01 folder
cd /u01
ssh root@192.168.100.180 "cat /volume1/orbackup/Finsys_WholeBackup_20-04-2013.tar" | tar xvf -
cd /u01
ssh root@192.168.100.180 "cat /volume1/orbackup/Finsys_WholeBackup_20-04-2013.tar" | tar xvf -
Create TAR tar archive to remote box
Examples:-
tar cvf - /u01/axigen | ssh root@192.168.100.99 "cat > /u01/axigen.tar"
tar zcvf - /data | ssh root@192.168.100.77"cat > /backup/data.tar.gz"
Create TAR to remote tape device# tar cvzf - /wwwdata | ssh root@192.168.1.201 "cat > /dev/nst0"
And now let us shortly explain this command
Usage: tar [OPTION]… [FILE]…
Let us check the option used in this example
-c, –create create a new archive
-z, –gzip, –ungzip filter the archive through gzip
-v, –verbose verbosely list files processed
-f, –file=ARCHIVE use archive file or device ARCHIVE
-C directory file
Performs a chdir operation on directory and performs the c (create) or r (replace) operation on file .
In c and r mode, this changes the directory before adding the following files. In x mode, change directories after opening the archive but before extracting entries from the archive.
No comments:
Post a Comment