1835346 Members
2462 Online
110078 Solutions
New Discussion

Re: tar question

 
SOLVED
Go to solution
Manuales
Super Advisor

tar question

hi...
i have a tar file named tests_2008.tar , i have two tests files wich have to be added into the file named tests_2008.tar .. how can i do that?
1.- do i have to uncompress the file and after add them?

please let me know.
thanks in advance.
Regards :)
7 REPLIES 7
Tim Nelson
Honored Contributor
Solution

Re: tar question

Should be able to use tar -rvf test_2008.tar file_list

this will append the new files to the end of the existing tar file. Make a copy of your tar file and test it out .

man tar

will get you all the needed info.
Manuales
Super Advisor

Re: tar question

ok ...
do not mind if i use a different absolute path for each file?
i mean ..

==================
---- CASE 1 ----
==================
tests_2008.tar file has files added with absolute path:
/home/robert/test1.txt
/home/robert/test2.txt
/home/robert/test3.txt
/home/robert/test4.txt
/home/robert/test5.txt
/home/robert/test6.txt

question 1:
if the first file to be added is located into /home/dani/test7.txt
and the second file to be added is located into /home/yami/test8.txt

how do i have to use tar commando to add it into the file tests_2008.tar and they be located into /home/robert/ directory?

do i have first to copy the files to be added into /home/robert/ directory? and if i do not have permissions?

==================
---- CASE 1 ----
==================
If the tar file tests_2008.tar contains files without absolute path,

question 1
how do i add the two files to be added without absolute path?
how do i add the two files to be added with absolute path (/home/dani/test7.txt and /home/dani/test8.txt) ?

please let us know.
thaks a lot, thanks in advance.


Steven E. Protter
Exalted Contributor

Re: tar question

Shalom,

Yes you can add files by absolute path.

You might run into trouble if you mix and match.

If every file's absolute path is preserved, that will be fine. But check the file with tar tvf and see what it looks like.

You may need to rebuild with an extra option to preserve full path.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Steven Schweda
Honored Contributor

Re: tar question

"man tar".

> [...]
> ---- CASE 1 ----
> [...]
> ---- CASE 1 ----
> [...]

Right.

> [...] absolute path [...]

Often, creating a "tar" archive with absolute
paths is not a good idea. Modern "tar"
programs have features which can help, but
old ones typically don't.

The paths in the "tar" archive are the paths
you specify when creating the archive. If
you want absolute paths, then specify
absolute paths. If you want relative paths,
then specify relative paths. "tar" doesn't
care.

> [...] and if i do not have permissions?

Then I guess that you won't be able to do it.

In general, it helps to think about how you
will be extracting the files from the archive
before you create the archive.
Bill Hassell
Honored Contributor

Re: tar question

tar is a very, very simple program. It will happily add the same file with an absolute pathname to the tar file hundreds of times. Some admins use this feature to save money by not buying lots of tapes. tar does not integrate or care anything about the current tar file -- it simply appends whatever you want to the end. This means that if you want the most recent version of a file, you have to wait until all other copies have been restored.

Having said that some admins like to save money, I must tell you that this a very unstable way to keep backups. One mistake and the entire tarfile or tape is useless.

tar does not compress anything. If you want to reduce the size of the tarfile, you must run compress on the tarfile.


Bill Hassell, sysadmin
OldSchool
Honored Contributor

Re: tar question

"how do i have to use tar commando to add it into the file tests_2008.tar and they be located into /home/robert/ directory?"

you don't. tar will store the absolute path name that was entered (or the relative path name), but has no mechanism that allows the stored path in the archive to be different then the file path originally entered.
Steven E. Protter
Exalted Contributor

Re: tar question

Shalom again.

Two reasons why I didn't give you the command syntax:
1) The tar man page in HP-UX is excellent.
2) Whole country here is on vacation and I don't have access to an HP-UX system.

But again, I emphasize what you want to do is quite possible assuming tar tvf does not show problems that force you to rebuild.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com