Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 
 

Oracle: Using the tar command

Expert Oracle Database Tips by Donald BurlesonMarch 22, 2015

Backing Up, Archiving, and Compressing Files

Several methods are available for backing up, archiving and compressing files on the Linux system.  Which method is used depends on which file or files are being backed up and if they should be compressed.

In this section, backing up specific data on the system will be shown.  These methods only create an additional copy of your files on the system but if there is a system failure, you would still lose them.  For long-term backup, these files should be copied to another system or removable media and preferably stored in a different physical location.  How you back up your entire system depends on your backup hardware and software and is beyond the scope of this book.

Here is a brief list of pros and cons of archiving and compression methods.  This should give a good start to deciding what method to use.

Method Pros Cons
tar Universally available, maintains permissions and other file information, handles multiple files very well Does not compress files
cpio Good compatibility between systems No compression, clumsy syntax
zip Format readable on nearly all platforms, good space saving on compression More space can be saved with other compression methods
gzip Very good space saving on compression, broadly adopted gzip utilities may not be available for some platforms
Table 13.5:  Pros and Cons of Common Archiving and Compression Methods

Using tar, the Tape Archiver

Originally written to manipulate magnetic tape devices, the tar command, short for tape archiver, can be used to create or read tar archives.  Tar archives, sometimes called tarballs, typically can be identified by the .tar file extension, though this is not a requirement.

The -cvf optionsare typically used to create tar files.  The -c indicates that you are creating an archive, -v tells tar that you would like verbose output, e.g. each file name and location will be printed as it is added to the archive, and the -f option tells tar that you are working with a file rather than a magnetic tape drive.

When creating archives, the tar command requires at least two arguments.  The first argument is the archive file with which to work.  The second argument is the file or directory to add to the archive.  Additional arguments can also be given to indicate more files to add to the archive.

$ tar -cvf notes.tar notes

notes/
notes/chapter3.txt
notes/chapter5.txt
notes/chapter2.txt
notes/chapter4.txt
notes/required_packages.txt
notes/chapter13.txt
notes/chapter1.txt
notes/chapter10.txt

To create a tar archive from a file or directory, it is best to cd to the directory the source resides in.  It is possible to specify the source directory with an absolute path, but that causes the files to be extracted to that path regardless of where the file is extracted from.

NOTE:  It may be noticed in some places that the dash (-) is omitted from the tar command options.  Options for tar can be specified with or without the dash.  Specifying options without the dash is an older method which is maintained in tar for compatibility.

To extract files from a tar archive, the -x optionis used instead of -c.  Files are extracted based on the current working directory as long as an absolute path was not used during archive creation.  Only one argument is needed to indicate where the tar archive can be found.

$ cd /tmp
$ tar -xvf /home/jemmons/notes.tar

notes/
notes/chapter3.txt
notes/chapter5.txt
notes/chapter2.txt
notes/chapter4.txt
notes/required_packages.txt
notes/chapter13.txt
notes/chapter1.txt
notes/chapter10.txt


Tar archives can be compressed using zip or gzip to save space.  If the archive is already created, it can be compressed using the method described in the part of this section on gzip, but if an archive needs to be created in a compressed format, add the -z option to the tar command.

$ tar -cvzf notes.tar.gz notes

notes/
notes/chapter3.txt
...

When using tar, the file names are arbitrary.  It is best to follow the common convention of .tar for tar archives and .tar.gz or .tgz for compressed tar archives.  If, for some reason, you are unsure of the contents of a file, use the file command to check it.

$ file notes.tar.gz

notes.tar.gz: gzip compressed data, from Unix, last modified: Sun Jan 17 13:07:47 2015

$ file notes.tar

notes.tar: POSIX tar archive

 

 

 
 
 
Get the Complete Details on
Linux System Management for Oracle DBAs  


The landmark book "Linux for the Oracle DBA: The Definitive Reference" provides comprehensive yet specific knowledge on administering Oracle on Linux.   A must-have reference for every DBA running or planning to run Oracle on a Linux platform.

Buy it for 30% off directly from the publisher.
 


 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.

 

 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster