Solaris tar command to backup data on tape device

Tar name come from Tape ARchiver. It is both a file format and the name of the program used to handle such file. Tar archive files have names ending in “.tar”. If an archive is compressed, the compression program adds its own suffix as usual, resulting in filename endings like “.tar.Z”, “.tar.gz”, and “.tar.bz2”. Tar doesn’t require any particular filename suffix in order to recognize a file as an archive. Tar was originally created for backups on magnetic tape, but it can be used to create tar files anywhere on a filesystem. Archives that have been created with tar are commonly referred to as tarballs.


Create a new set of backup

To create a Tar file, use tar command as follows:
# tar cvf /dev/rmt/X file1 file2 dir1 dir2 file2 …

  • c – Create a new files on tape/archive
  • v – verbose i.e. show list of files while backing up
  • f – tape device name or file

For example, backup /export/home/vivek/sprj directory to tape device /dev/rmt/0, enter
# tar cvf /dev/rmt/0 /export/home/vivek/sprj/
Remember c option should only use to create new set of backup.

Appending or backing up more files to same tape using tar

tar provides r option for appending files to tape. For example to backup /data2/tprj/alpha1 files to same tape i.e. appending files to a first tape device:
# tar rvf /dev/rmt/0 /data2/tprj/alpha1/*

  • r – append files to the end of an archive/tape

List files on a tape using tar command

To display file listing of a first tape use tar as follows:
# tar tvf /dev/rmt/0
To listing the Contents of a Stored Directory (for example wwwroot directory):
# tar tvf /dev/rmt/0 wwwroot

  • t – list the contents of an archive/tape

Retrieve / restore tape backup taken with tar

1) Use tar command as follows to retrieve tape drive backup to current directory:
(a) Change directory where you would like to restore files:
# cd /path/to/restore
# pwd

(b) Now, do a restore from tape:
# tar xvf /dev/rmt/0

To specify target directory use –C option

Restore everything to /data2 directory:
# tar xvf /dev/rmt/0 –C /data2
To retrieve directory or file use tar as follows:
# tar xvf /dev/rmt/0 tprj
Note that Solaris tar command is little different from GNU tar, if you wish to use gnu tar with Solaris use command gtar. Gnu tar accepts same command line options plus bunch of additional options 🙂

See Sun Solaris tar man page and tapes ~ creates /dev entries for tape drives attached to the system.

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

21 comments… add one
  • Karthik Apr 7, 2005 @ 2:29

    how would i create a tar file so it does not copy the tar directory structure. For example:
    tar -cf temp.tar /usr/local/myfile.txt

    I dont want to have the directory structure in the tar file. I dont want “/usr/local/” in the tar file. I just want to file to be stored in the tar file.

  • Karthik Apr 7, 2005 @ 2:30

    how would i create a tar file so it does not copy the tar directory structure. For example:
    tar -cf temp.tar /usr/local/myfile.txt

    I dont want to have the directory structure in the tar file. I dont want “/usr/local/” in the tar file. I just want to file to be stored in the tar file.

  • Anonymous Apr 10, 2005 @ 18:43


    Try format

    tar –cvf file1 file2

    By default it includes directory name however you can pass the following x or fF arguments to tar

    tar –cvf –x dir1, dir2 .

    x Exclude. Use the exclude-filename argument as a
    file containing a list of named files (or
    directories) to be excluded from the tarfile when using the key letters c, x, or t.

    F – With one F argument, tar will exclude all direc tories named SCCS from the tarfile. With two argu ments, FF , tar will exclude all directories named SCCS

  • vinothkumar Jun 16, 2007 @ 14:23

    hi suppose i took a tape backup entire but my hard disk crashed . i want to recover this partition slice table whether it’s possible or not.plz help to sort it out

  • 🛡️ Vivek Gite (Author and Admin) nixCraft Jun 16, 2007 @ 18:49

    Just restore data from tape to hard disk. Did you used tar or dump command?

  • tamer Jul 18, 2007 @ 11:32

    when i do this
    tar xvf /dev/rmt/0 tamer

    where is tamer is a dir in the tape .

    befor i didthis command im allredy in th path where i whant this dir to besor in

    but whene i check i cannot find the data

    hellp me pls

    • hayan May 21, 2013 @ 10:36

      enter -C to extract a specific directory.
      like this
      tar xvf /dev/rmt/0 -C tamer

      hope it help

  • Mohan Aug 23, 2007 @ 17:27

    Is there a way to check how much used space / freespace in the tape

  • madhu Dec 10, 2007 @ 18:53

    How do you only restore a specific file type onto a specific folder ?
    Also, is there a way to restore files depending on date ?

  • Narith Dec 17, 2008 @ 4:58

    Hi madhu,

    I ever try to find command to restore a specific file or dir too, but i cannot find it.
    Now i can use WinRAR program on Window. I just open tar or tar.gz file with this program, i can extract some files or dirs i want.

    If you found other option pls share. 🙂

  • nagaraju Feb 26, 2009 @ 3:56

    hoe to configure NIS server in Solaries 5.10

  • nagaraju Feb 26, 2009 @ 3:59

    how to configure DNS server in Solaries 5.10,
    how to created Solaries partitions,
    how to configured APACHE

  • sollin Mar 20, 2009 @ 7:13

    hi can i know how to identify the tape is write protected… please help me

  • Nagesh Apr 7, 2009 @ 18:46


    how to remove tar file in media.

  • Rajasekar Aug 26, 2009 @ 9:36

    How to take file backup and restore in solaris ,and differenc between ufsdump and tar commmand

  • SYED Apr 13, 2010 @ 7:25

    how can i take solaris system backup using tar command?

  • kb Apr 22, 2010 @ 6:54


    why after i’ve made a daily backup, capacity for mounted on ‘/’ is 100%???i have to run rm * everyday to reduce the capacity from 100%. actually i think that the backup data went to ‘/’ and also to my backup tape.


  • Ravi`` Oct 11, 2010 @ 18:17

    What is meaning of GNU tar in solaris

  • mihai Sep 17, 2011 @ 0:12

    hey … i want to tar in solaris….pleas help me:

    SunOS 5.11 snv_89 i86pc i386 i86pc
    tar xvf me.tar
    tar: directory checksum error

  • hany Oct 13, 2011 @ 11:20


    tar rvf /dev/rmt0 filename is not working with me
    using AIX, testing a 4k file, it take long time with no response…

    any help

  • somebody May 28, 2013 @ 11:10

    $ tar cvf home.tar /home/app
    tar: Removing leading `/’ from member names
    Why i’m getting this :” tar: Removing leading `/’ from member names ”

    can someone tell me !!!!

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.