Networking

Unix and Linux network configuration. Multiple network interfaces. Bridged NICs. High-availability network configurations.

Applications

Reviews of latest Unix and Linux software. Helpful tips for application support admins. Automating application support.

Data

Disk partitioning, filesystems, directories, and files. Volume management, logical volumes, HA filesystems. Backups and disaster recovery.

Monitoring

Distributed server monitoring. Server performance and capacity planning. Monitoring applications, network status and user activity.

Commands & Shells

Cool Unix shell commands and options. Command-line tools and application. Things every Unix sysadmin needs to know.

Home » Backups, Commands & Shells

Create tarball

Submitted by on November 19, 2005 – 10:42 pm 2 Comments

The Unix tar command creates an archive of files and directories while preserving directory structure, file permissions and ownership information. This command is ideally suited for creating backups of most types of data. Many open-source and commercial backup applications use the tar command.

The basic syntax of the tar command with some common options for creating a “tarball” and unpacking one, respectively:

tar cvf tarball.tar 
tar xvf tarball.tar

The example below uses tar to copy directory /usr/openv to /usr/openv2

mkdir /usr/openv2
cd /usr/openv
du -sk openv
tar cvf /usr/openv2/tarball.tar .
cd /usr/openv2
tar xvf tarball.tar
rm tarball.tar

*by default tar will not follow links > can force it to w/t parameter

In the following example we create a tarball of all *.conf files found in /etc/directory. This can be useful for making a quick backup of your server’s vital configuration files before messing with them.

tar cvf - `find /etc -name "*.conf" -print` > /var/tmp/etc_conf.tar

Print Friendly, PDF & Email

2 Comments »

  • John G says:

    I have a PERL script creating a TAR archive via PERL’s Archive::TAR class. I get a listing of the files & directory structure by recursing through the tree & putting all into a list.

    Then I use: $TarObject->create_archive
    ($ArchiveFile, $CompressionLevel, @FilesToTar); where I have used compression levels 2 & 9. These create TARs of about 40+ MB.

    When I retrieve the TARs to my workstation I attempt to run them through tar -xzvf and I get:
    tar: Skipping to next header
    tar: Archive contains obsolescent base-64 headers

    gzip: stdin: invalid compressed data–format violated
    tar: Child returned status 1
    tar: Error exit delayed from previous errors

    I have attempted to use gzip & uncompress as well.

    Any ideas?
    Thanks
    Mark
    OT, A little further research led me to tweaking my code to set the transfer mode to binary and that was it, I was able to completely untar & gunzip the files after that. You get best answer when I can choose.
    Thanks
    Mark

  • Joey 01 says:

    http://www.fedorafaq.org/#flash

    I got the command prompts from this site and I keep getting the response; nothing to do.

    What could be going wrong?
    I just installed the OS so I know Flash is not on my computer

Leave a Reply to John G Cancel reply

%d bloggers like this: