Wednesday, September 18, 2019

Using TAR Utility

tar.gz file is a combination of a .tar file and a .gz file. It is an archive file with several other files inside it.

Create TAR.gz


Simple TAR file of a Specific location

    
    [oracle@server]$                tar -cvf file_name.tar.gz /home/d01/oracle

Create simple TAR file of a Specific Location & save on /home/oracle/backup/ folder


    [oracle@server]$                tar -cvf /home/oracle/backup/file_name.tar.gz /home/d01/oracle

  • c – creates a new archive
  • v – verbose, meaning it lists the files it includes
  • f – specifies the name of the file

Create compressed TAR file

    Add the -z option to create a compressed GNUZIP file

    [oracle@server]$    tar -cvzf file_name.tar.gz /home/d01/oracle
    [oracle@server]$    tar -cvzf /home/oracle/backup/file_name.tar.gz /home/d01/oracle


Extract TAR file

    You can unzip these files the same way you would unzip a regular zipped file:

Extract TAR file


    [oracle@server]$     tar -xvzf filename.tar

  • x – instructs tar to extract the files from the zipped file
  • v – to list out the files it’s extracting
  • z – instructs tar to decompress the files
  • f – tells tar the filename you want it to work on

Extract TAR file in specific /home/oracle/clone/db folder

    
    [oracle@server]$    tar –xvzf documents.tar.gz –C /home/oracle/clone/db/