Link to home
Start Free TrialLog in
Avatar of msnr
msnr

asked on

tar option

Hi,

I have huge amount of data which has to be backedup on a two tapes using tar command.
How can i run tar so that once the first tape is fulled it has to prompt for second tape, and the rest of the data only has to go inside the second tape.


ASKER CERTIFIED SOLUTION
Avatar of yuzh
yuzh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of yuzh
yuzh

Here's some example for using cpio command:

1. To copy file to your tape:

(use find, ls creat a list of files to be copied)

cat list | cpio -oacv -O /dev/rmt/0n

or:

find dir1 dir2 -print | cpio -oacv -O /dev/rmt/0n

(replace /dev/rmt/0n with the real tape device name on your system)

2. To verify what's on the tape:

   cpio -ictv < /dev/rmt/0n

3. To extra files from the tape:
   cd to the dir you want to extra the file to:
   cpio -icdmuv -I /dev/rmt/0n

   Note: cpio can be use for system level backup. since you are using Solaris, use ufsdump & ufsrestore is recommanded for system level backup.

Why do you need to use tar ?
Besides the multivolume problem tar
also has a limit of 155 chars in
the path to a file. This is usually a
problem when used for backups.
(gtar from gnu can solve this one)

ufsdump will create a backup and
prompt you for next volume.

OR depending on the amount of data,
jar has same options as tar but will also
compress files before storing them.

OR you can use cpio, as yuzh pointed out
Avatar of msnr

ASKER

besky,
i will check ufsdump option, meanwhile will tar prompt
for next volume.?


msnr
tar should prompt you when it reaches the end of the tape, e.g.
 .
 .
a /etc/lvmconf/test2.conf 454 blocks
a /etc/lvmconf/test2.conf.old 454 blocks
Tar: end of tape
Tar: to continue, enter device/file name when ready or null string to quit.

After changing the tape, enter the name of the tape device and hit <Enter> to continue (Or give it the name of another tape drive, if you have more than one)

The nice thing about tar is it allows you to transfer datafiles to other Unixes and even NT. But for backups etc. you're better off using cpio of ufsdump.


The GUN version of tar works better than the native Solaris tar, it can handle longer path-to-file name and multi-volumes.

You can download it from:
      http://sunfreeware.com/

    tar is handy and good enough for backup regular file, but it have trouble to handle some of the special file such as device file, symbolic link (if you use -h option, tar follow the link and copy the file, it does not keep the symbolic link !).

    Note: I experienced some of application data included device files and symbolic link (eg, micro-eletronic desing simulation result).

MSNR,
   Here is the script (slightly modified for confidentiality) I use to create a hot backup of our systems to a local tape drive.  MAN the UFSDUMP command. Solaris (above 2.4) allows you to name a remote tape drive (not shown here), provided you have access to the remote tape drive (read: .rhosts or /etc/hosts.equiv).  


!/bin/csh
echo ""                                    | tee -a server_fulldump.rpt
echo "::::::::::::::::::::::::::::::::::::::::"      | tee -a server_fulldump.rpt
echo "Level Zero dump of server using"            | tee -a server_fulldump.rpt
echo "server_bkup.csh on"                  | tee -a server_fulldump.rpt
/usr/bin/date                              | tee -a server_fulldump.rpt
echo "::::::::::::::::::::::::::::::::::::::::"      | tee -a server_fulldump.rpt
echo ""                                    | tee -a server_fulldump.rpt
echo ""                                    | tee -a server_fulldump.rpt
echo "Filesystems that'll be saved to tape are:"| tee -a server_fulldump.rpt
echo ""                                    | tee -a server_fulldump.rpt
echo "  1.  / (root) at /dev/rdsk/c0t0d0s0"      | tee -a server_fulldump.rpt
echo ""                                    | tee -a server_fulldump.rpt
echo "  2.  /var at     /dev/rdsk/c0t0d0s3"      | tee -a server_fulldump.rpt
echo ""                                    | tee -a server_fulldump.rpt
echo "  3.  /home at    /dev/rdsk/c0t0d0s6"      | tee -a server_fulldump.rpt
echo ""                                    | tee -a server_fulldump.rpt
echo "  4.  /opt at     /dev/rdsk/c0t0d0s4"      | tee -a server_fulldump.rpt
echo ""                                    | tee -a server_fulldump.rpt
echo "  5.  /home1 at   /dev/rdsk/c0t0d0s5"      | tee -a server_fulldump.rpt
echo ""                                    | tee -a server_fulldump.rpt
echo ""                                    | tee -a server_fulldump.rpt
echo "Starting level 0 using server_bkup.csh:"      | tee -a server_fulldump.rpt
echo ""                                | tee -a server_fulldump.rpt
echo "/ (root) started at"                  | tee -a server_fulldump.rpt
/usr/bin/date                              | tee -a server_fulldump.rpt
/usr/sbin/ufsdump 0cf /dev/rmt/0hn /dev/rdsk/c0t0d0s0
echo ""                                    | tee -a server_fulldump.rpt
echo "/ (root) dump completed at"            | tee -a server_fulldump.rpt
/usr/bin/date                               | tee -a server_fulldump.rpt
echo ""                                    | tee -a server_fulldump.rpt
echo ""                                    | tee -a server_fulldump.rpt
echo "/var started at"                        | tee -a server_fulldump.rpt
/usr/bin/date                              | tee -a server_fulldump.rpt
/usr/sbin/ufsdump 0cf /dev/rmt/0hn /dev/rdsk/c0t0d0s3
echo ""                                    | tee -a server_fulldump.rpt
echo "/var dump completed at"                  | tee -a server_fulldump.rpt
/usr/bin/date                               | tee -a server_fulldump.rpt
echo ""                                    | tee -a server_fulldump.rpt
echo ""                                    | tee -a server_fulldump.rpt
echo "/home started at"                        | tee -a server_fulldump.rpt
/usr/bin/date                              | tee -a server_fulldump.rpt
/usr/sbin/ufsdump 0cf /dev/rmt/0hn /dev/rdsk/c0t0d0s6
echo ""                                    | tee -a server_fulldump.rpt
echo "/home dump completed at"                  | tee -a server_fulldump.rpt
/usr/bin/date                              | tee -a server_fulldump.rpt
echo ""                                    | tee -a server_fulldump.rpt
echo ""                                    | tee -a server_fulldump.rpt
echo "/opt started at"                        | tee -a server_fulldump.rpt
/usr/bin/date                              | tee -a server_fulldump.rpt
/usr/sbin/ufsdump 0cf /dev/rmt/0hn /dev/rdsk/c0t0d0s4
echo ""                                    | tee -a server_fulldump.rpt
echo "/opt dump completed at"                  | tee -a server_fulldump.rpt
/usr/bin/date                              | tee -a server_fulldump.rpt
echo ""                                    | tee -a server_fulldump.rpt
echo ""                                    | tee -a server_fulldump.rpt
echo "/home1 started at"                  | tee -a server_fulldump.rpt
/usr/bin/date                              | tee -a server_fulldump.rpt
/usr/sbin/ufsdump 0cf /dev/rmt/0hn /dev/rdsk/c0t0d0s5
echo ""                                    | tee -a server_fulldump.rpt
echo "/home1 dump completed at"                  | tee -a server_fulldump.rpt
/usr/bin/date                               | tee -a server_fulldump.rpt
echo ""                                    | tee -a server_fulldump.rpt
echo ""                                    | tee -a server_fulldump.rpt
/usr/bin/mt -f /dev/rmt/0 rewoffl
echo ""                                    | tee -a server_fulldump.rpt
echo "Done with server_bkup.csh"            | tee -a server_fulldump.rpt
echo "Remove the tape."                        | tee -a server_fulldump.rpt
echo ""                                     | tee -a server_fulldump.rpt
echo ""                                    | tee -a server_fulldump.rpt


Just cut-n-paste code to a file (server_bkup.csh), modify it to match your partitions (look at disk using the format command and the file /etc/vfstab), ftp it to your machine and set ownership/permissions on the file.

To execute, try this (from the root directory as super-user):

/usr/bin/nohup /server_bkup.csh &

This will run in the background, spool screen output to the file nohup.out, and most importantly, will allow you to close out your login sessions without ending the backup. You will actually get 2 reports from this, the nohup.out report and the server_fulldump.rpt. As a sidebar, do not use the C-shell's built-in nohup command, as it is only as effective as long as the terminal is not closed (if your are working from an xterm, you would not be able to close it).

Cheers,
Stephen
No comment has been added lately, so it's time to clean up this Topic Area.
I will leave a recommendation for this question in the Cleanup topic area as follows:

- PAQ, no points refunded

Please leave any comments here within the next 7 days

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

tfewster
Cleanup Volunteer
Here are correct solutions for his problem (Not use tar!)
yuzh, I agree but there is no obvious "best" answer; cpio & GNU tar do the job and are portable, but ufsdump is preferred for Solaris.

Please make a recommendation on which comment(s) should get points. (Ideally msnr should select the answer that was most helpful to him/her, but that may not happen)
cpio will work for any UNIX favour. (it can also handle system level backup
Answered by yuhz (appears to be the first answer in that works)

SpideyMod
Community Support Moderator @Experts Exchange