Operating System - HP-UX
1833777 Members
1994 Online
110063 Solutions
New Discussion

Re: tar Backs UP device Files !!!!!!

 
Sundar_7
Honored Contributor

tar Backs UP device Files !!!!!!


tar backs up Device Files !

But loads of posts in ITRC says tar cannot back up device files..

# cd /dev/rdsk
# tar -cvf /home/sr151/devfil.TAR .
..
..
#
# cd /home/sr151
# tar -xvf devfil.TAR .
..
..
# ls c*
c100d...
c...
..
#

So now what is the difference between cpio and tar or am I not understanding something ..

Please clear me

Sure I wont fail to assign points

Sundar



Learn What to do ,How to do and more importantly When to do ?
7 REPLIES 7
Edward Alfert_2
Respected Contributor

Re: tar Backs UP device Files !!!!!!

tar creates on huge file that compresses many individual files... you can then extract the files to restore them.

cpio copies each file individually onto the tape without compressing it.

I use cpio on my servers.. i find it easier to restore individual files.

"Do what you love and you will never work a day in your life." - Confucius
Stefan Farrelly
Honored Contributor

Re: tar Backs UP device Files !!!!!!


I dunno who said tar cannot backup device files. I just tried it, works fine and restores fine also.
Im from Palmerston North, New Zealand, but somehow ended up in London...
linuxfan
Honored Contributor

Re: tar Backs UP device Files !!!!!!

Hi,

Tar doesn't care what kind of file it is, the only limitations AFAIK , from the manpages of tar

Tar does not support archival of files larger than 2GB or files that have user/group IDs greater than 60K.
There is also a limitation to the number of characters in the filename or link name.

-HTH
Ramesh
They think they know but don't. At least I know I don't know - Socrates
Edward Alfert_2
Respected Contributor

Re: tar Backs UP device Files !!!!!!

since you assigned low points i assume we didn't answer your question fully. this is the summary of tar and cpio direct from HP:

tar
The tar command only offers a limited number of options.
Effort is very high for restoring files and directories selectively.
The best way to restore a complete tar backup is to enter:
tar -xvf
If you do not want to see the listing of the files, simply leave out the v option.
To determine the contents of a tar archive, use the following syntax
(with tar, the device file can also be a normal file):
tar -tvf
Individual files can be restored by attaching their names to the command line prompt. For example:

tar -xvf /dev/rmt/0m /etc/hosts /etc/resolv.conf
Tar does not allow you to exclude files/directories from the backup, so you do not have the option of leaving out the LVM configuration files as you do with frecover.
Also when using the tar command, the system should be rebooted whenever a root disk has been restored.
If data affecting the system has been restored - this is all data which is not user data - a shutdown -r should always be performed immediately so that the system does not become inconsistent.



cpio
Cpio is one of the least commonly used backup/recovery tools. It is only intended for small file systems. Also it should be noted that it cannot save block files, character files and device files. Full backups are usually created using the find(1) command in combination with cpio.
Example:
find / -print | cpio -ov > /dev/rmt/0m absolute
ls | cpio -ov > /dev/rmt/0m relative
Cpio makes a version comparison of the file which is to be restored and only overwrites it if you use the -u option. It is important to know whether the backup was made relative or absolute to the paths. The restore is only possible accordingly.
Restore everything by overwriting the files available using -u, create directories not present using -d, display file names using -v and read files from the tape using -i:
cpio -iuvd <
Restore individual files:
cpio -iv <
It is also possible here to use regular expressions and meta symbols for file names in order to mask directories or files.

If system level files are restored, it is important to reboot the system to ensure consistency. Do so with a shutdown -r command.
"Do what you love and you will never work a day in your life." - Confucius
Joseph C. Denman
Honored Contributor

Re: tar Backs UP device Files !!!!!!

cpio is a much more powerful tool than tar. Not to say that tar is bad. Most people use tar because it is relatively easy to use. Probably the biggest different would be the number of options cpio provides you as well as the ability to stream data.

Copying files from on dir to another:

tar
cd fromdir;tar -cf - . | (cd todir;tar -xf -)

cpio
cd fromdir;find . | cpio -pdmuxvl /newdir

...jcd...
If I had only read the instructions first??
Madhu Sudhan_1
Respected Contributor

Re: tar Backs UP device Files !!!!!!

Sundar !

Tar cann't backup files > 2gb. There is no large file support with tar.

...Madhu
Think Positive
Tom Danzig
Honored Contributor

Re: tar Backs UP device Files !!!!!!

The posix compliant version of tar will back up device files.