Solaris UNIX Tape Backup And Recovery With tar And cpio Commands

We have recently brought a new Sun Solaris UNIX server. How do I Backup data and make a recovery for the Solaris OS using tar and tape device?

It cannot be stressed enough how important it is to make a backup of your Solaris UNIX system. Most of the actions listed in this post are written with the assumption that they will be executed by the root user running the sh, ksh, or any other modern shell. Use the following tools to backup data to other server.

Sun Solaris UNIX Backup Commands

Sun Solaris UNIX comes with various commands and utilities to make a backup and recovery job:

a) tar command
b) cpio command

Important Directories and Files to Backup

  1. /export/home or /home (Home directory)
  2. /etc
  3. User mailboes
  4. Cron files (/var)
  5. MySQL and Oracle databases etc

Task: Use tar command to backup /data and /home directory

Usually /dev/rmt/0 is tape device name. To create a new tar file you can type the following command (backup /home/, /data/ and, /etc/file1 files to home.back.tar file) :
# tar cvf home-back.tar /home /data /etc/file1

To create a new tape backup use:

Backup /home and /data directory to /dev/rmt/0 tape device, enter:
# tar cvf /dev/rmt/0 /home /data

Task: Display the contents of a tar file/tape

Pass tvf option to a tar command:
# tar tvf home-back.tar
# tar tvf /dev/rmt/0

Task: Restore files from tar file / tape

To extract the tar file to the current directory type:
# cd /
tar xvf home-back.tar
# tar xvf /dev/rmt/0

Understanding tar command options:

  • x : Extract tar file
  • v : Verbose
  • f : filename : Use to specify file name / tape device name
  • t : List tar file contents

Task: Backup files with cpio command

You can also use cpio command, which copies files into and out of a cpio archive. The cpio archive may span multiple volumes. The -i, -o, and -p options select the action to be performed. For example copy all *.c files to tape device or file called prog.cpio:
# ls *.c | cpio -oVc > /dev/rmt/0
# ls *.c | cpio -oVc > prog.cpio

Task: Restore file using cpio

To copy from tape back to a directory, use the command as follows:
# cpio -icvD
# cpio -icvum

Task: View the contents of cpio

Use the command as follows:
# cpio -ict

Understanding cpio command options:

  • i : (copy in) Reads an archive from the standard input and conditionally extracts the files contained in it and places them into the current directory tree.
  • c : Reads or writes header information in ASCII character form for portability.
  • t : Prints a table of contents of the input.
  • o : (copy out) Reads a list of file path names from the standard input and copies those files to the standard output in the form of a cpio archive.
  • v : Verbose
  • u : Use for an unconditional copy; old files will not replace newer versions.
  • m ; Retains previous file modification time.
  • d: Create as many directories as needed.


  • Read Solaris tar, tape and cpio man pages, by typing following command:

man tar
man tape
man cpio

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 1 comment so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
1 comment… add one
  • Kuldeep Nov 20, 2012 @ 17:57

    Can you please guide how we can take incremental backup in Solaris?

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum