- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: newbie tar question!
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2002 01:36 AM
06-20-2002 01:36 AM
can't say that I do many backups at all, so pretty new to tars features!
Currently I have 2 problems:
1>
/home/bill/file1
/home/bill/file2
/home/bill/file3
/home/bill/file4
tar -cvf /bill.tar /home/bill/file1 /home/bill/file2 /home/bill/file3 /home/bill/file4
Great! created a tar file!
vi file1, save and make realise after doing this:
tar -uvf /bill.tar /home/bill/file1
that I made a stupid error.
(and forgot the contents of the original)
now:
tar -tvf /bill.tar
/home/bill/file1 18th June
/home/bill/file2 18th June
/home/bill/file3 18th June
/home/bill/file4 18th June
/home/bill/file1 19th June
mmm, maybe I can recover file1 from the 18th June.. but
not via tar -xvf /bill.tar
How do I do this.
2>
secondly, before I archive this, how can I tar -uvf to really replace the file1, ie, If I don't want the two versions..
Thanks,
Bill
Solved! Go to Solution.
- Tags:
- tar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2002 01:46 AM
06-20-2002 01:46 AM
Re: newbie tar question!
A sys admin of your experience... shame...
You wanted to recover, my suggestion is to
move the original /home/bill to /home/bill1
or something else.
The reason I say this is that when using
tar never, ever use the full pathname,
use ./dir/files
2> Do the same thing again after moving
/home/bill to /home/bill2
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2002 02:10 AM
06-20-2002 02:10 AM
Re: newbie tar question!
from "man tar"
Note that if several files with the same name are on the archive, the last one overwrites all earlier ones.
If you want to do some version management for diffrent versions of scripts, configfiles or so, you should take a look at "sccs". I guess without a timestamp based naming convention for tar-archives, tar would not be the right tool. In addition, one should not use absolute pathnames in tar, because you might have trouble to relocate to a diffrent location.
Hope this helps
Volker
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2002 02:18 AM
06-20-2002 02:18 AM
Re: newbie tar question!
cd where-you-want-the-files
pax -r -s ',//*home/bill//*,,' -f /dev/rmt/0m
For getting the first file1 you could probably start the extraction and interrumt it after having read the first file1, or you can use the '-i' option to pax.
You can't replace a file on a tar, only add (to the end).
Regards,
Trond
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2002 02:28 AM
06-20-2002 02:28 AM
Re: newbie tar question!
> interrupt it after having
> read the first file1,
It goes a little too fast to do this ;)
> or you can use the '-i' option to pax.
This is good!
But I'd prefer a tar command!
Nobody yet has really answered my question (I don't think you read it fully either!)
For a start, the files do need to be absolute to root because it's a software installation (and my example here is minimal - there are really more than 800 files in the tar, but the problem is the same.)
The tar extraction is handled via a non interuptable install script, and in either case is too quick to interupt.
The questions simply are:
how do I extract both file1's individually via tar.
and,
after the tar is created, how do I delete/upgrade the tar so that only one file1 exists.
I don't think it's possible myself given the origins of tar..
Later,
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2002 02:53 AM
06-20-2002 02:53 AM
Re: newbie tar question!
I don't think restoring the old file can be done. The second "file1" will overwrite the first "file1".
I don't think you can remove the first one from the archive either.
Vince
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2002 03:01 AM
06-20-2002 03:01 AM
Solution2> No, not with tar.
tar can only ADD files to the (end of the) archive.
Regards,
Trond
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2002 03:17 AM
06-20-2002 03:17 AM
Re: newbie tar question!
Remember that annoying confirmation message that comes up when trying to overwrite or delete a file as a non-root user, that is owned by someone else?
Try extracting the files once as root, then again as a non-root user. This should (hopefully) force tar to prompt for 'overwrite y/n', so you can selectively restore the files, and perhaps Ctrl-C to halt at the next prompted file?
Also, does the 'tar -uvf' option add to the end, or update the existing file?
Share and Enjoy! Ian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2002 03:23 AM
06-20-2002 03:23 AM
Re: newbie tar question!
pax is the only way, UNLESS you get and install GNU's tar.
http://www.sunsite.ualberta.ca/Documentation/Gnu/tar-1.13/html_mono/tar.html
Here's a PAX example:
# tar -tvf zfile.tar
rw-r----- 0/3 105707 Jun 20 07:22 2002 /tmp/zfile1.txt
rw-r----- 0/3 105707 Jun 20 07:22 2002 /tmp/zfile2.txt
rw-r----- 0/3 105707 Jun 20 07:22 2002 /tmp/zfile3.txt
rw-r----- 0/3 105707 Jun 20 07:22 2002 /tmp/zfile4.txt
rw-r----- 0/3 1315 Jun 20 07:23 2002 /tmp/zfile1.txt
# ll zfile*
-rw-rw-rw- 1 root sys 430080 Jun 20 07:23 zfile.tar
-rw-r----- 1 root sys 105707 Jun 20 07:22 zfile1.txt
-rw-r----- 1 root sys 105707 Jun 20 07:22 zfile2.txt
-rw-r----- 1 root sys 105707 Jun 20 07:22 zfile3.txt
-rw-r----- 1 root sys 105707 Jun 20 07:22 zfile4.txt
# pax -r -x ustar -y -f zfile.tar
extract /tmp/zfile1.txt? n
extract /tmp/zfile2.txt? n
extract /tmp/zfile3.txt? n
extract /tmp/zfile4.txt? n
extract /tmp/zfile1.txt? y
# ll zfile*
-rw-rw-rw- 1 root sys 430080 Jun 20 07:23 zfile.tar
-rw-r----- 1 root sys 1315 Jun 20 07:23 zfile1.txt
-rw-r----- 1 root sys 105707 Jun 20 07:22 zfile2.txt
-rw-r----- 1 root sys 105707 Jun 20 07:22 zfile3.txt
-rw-r----- 1 root sys 105707 Jun 20 07:22 zfile4.txt
#
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2002 03:28 AM
06-20-2002 03:28 AM
Re: newbie tar question!
2 - Why update your tar file and then change your mind and go back to the old version! It is handy of tar to allow you to do this, but the feature does not extend as far as you would like.... It just so happens that 18 June files can be extracted as Vince has said (effectively utilising a loophole) and if you want the whole 19 June just do full extract.
That said try
18 June
dd if=/bill.tar bs=
19 June
tar xvf /bill.tar /..../file1
Regards
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2002 03:28 AM
06-20-2002 03:28 AM
Re: newbie tar question!
"ar" has update and positioning options.
Volker
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2002 03:36 AM
06-20-2002 03:36 AM
Re: newbie tar question!
l1:/tmp 105 > tar cvf xx.tar xx.c xx.o
a xx.c 1 blocks
a xx.o 2 blocks
l1:/tmp 106 > tar tvf xx.tar
rw-rw-rw- 203/200 9 May 27 13:23 2002 xx.c
rw-rw-rw- 203/200 732 May 27 13:23 2002 xx.o
l1:/tmp 107 > touch xx.c
l1:/tmp 108 > tar uvf xx.tar xx.c
a xx.c 1 blocks
l1:/tmp 109 > tar tvf xx.tar
rw-rw-rw- 203/200 9 May 27 13:23 2002 xx.c
rw-rw-rw- 203/200 732 May 27 13:23 2002 xx.o
rw-rw-rw- 203/200 9 Jun 20 13:02 2002 xx.c
l1:/tmp 110 >
l1:/tmp/test 144 > xx.pl ../xx.tar
Opening archive ../xx.tar ...
x xx.c ...
x xx.o ...
x xx.c ...
WHOA! xx.c appeared in this archive before
New file extracted as xx.c.1
l1:/tmp/test 145 > ll
total 15
791 drwxrwxrwx 2 merijn softwr 96 Jun 20 13:40 .
2 drwxrwxrwx 19 root root 11264 Jun 20 13:40 ..
837 -rw-rw-rw- 1 merijn softwr 9 May 27 13:23 xx.c
830 -rw-rw-rw- 1 merijn softwr 9 Jun 20 13:02 xx.c.1
839 -rw-rw-rw- 1 merijn softwr 732 May 27 13:23 xx.o
702 -rwxr-xr-x 1 merijn softwr 815 Jun 20 13:40 xx.pl
l1:/tmp/test 146 >
l1:/tmp/test 146 > cat xx.pl
#!/pro/bin/perl -w
use strict;
use Archive::Tar;
use File::Copy;
my %done;
print STDERR "Opening archive $ARGV[0] ...\n";
my $tar = Archive::Tar->new (shift);
for ($tar->list_files ([qw(name uid gid mtime mode)])) {
my $name = $_->{name};
print STDERR "x $name ... ";
my $new = $name;
if ($done{$name}++) {
my $idx = 1;
$idx++ while -f "$new.$idx";
$new .= ".$idx";
print STDERR "\nWHOA! $name appeared in this archive before\n",
"New file extracted as $new";
move ($name, "$new.$$");
}
-f $new and print STDERR " already exists";
$tar->extract ($name);
utime $_->{mtime}, $_->{mtime}, $name;
chmod $_->{mode}, $name;
chown $_->{uid}, $_->{gid}, $name;
print STDERR "\n";
$name eq $new and next;
move ($name, $new);
move ("$new.$$", $name);
}
l1:/tmp/test 147 >
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2002 03:56 AM
06-20-2002 03:56 AM
Re: newbie tar question!
Sorry I screwed up the order you wanted, using pax, it would be like this:
# tar -tvf zfile.tar
rw-r----- 0/3 105707 Jun 20 07:22 2002 /tmp/zfile1.txt
rw-r----- 0/3 105707 Jun 20 07:22 2002 /tmp/zfile2.txt
rw-r----- 0/3 105707 Jun 20 07:22 2002 /tmp/zfile3.txt
rw-r----- 0/3 105707 Jun 20 07:22 2002 /tmp/zfile4.txt
rw-r----- 0/3 1315 Jun 20 07:23 2002 /tmp/zfile1.txt
# pax -r -x ustar -y -f zfile.tar
extract /tmp/zfile1.txt? y
extract /tmp/zfile2.txt? n
extract /tmp/zfile3.txt? n
extract /tmp/zfile4.txt? n
extract /tmp/zfile1.txt? n
# ll zfile*
-rw-rw-rw- 1 root sys 430080 Jun 20 07:23 zfile.tar
-rw-r----- 1 root sys 105707 Jun 20 07:22 zfile1.txt
-rw-r----- 1 root sys 105707 Jun 20 07:22 zfile2.txt
-rw-r----- 1 root sys 105707 Jun 20 07:22 zfile3.txt
-rw-r----- 1 root sys 105707 Jun 20 07:22 zfile4.txt
#
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2002 05:13 AM
06-20-2002 05:13 AM
Re: newbie tar question!
that's cleared that one up!
Later,
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2002 05:20 AM
06-20-2002 05:20 AM
Re: newbie tar question!
>
> how do I extract both file1's individually via tar.
Bill, I am somewhat disappointed in you! :-)
First Trond gives a perfectly good solution ("pax -i"). But no, not only are you 'stubborn' enough to not use pax (which is a superset of tar and cpio and an XPG/POSIX standard command to boot), but you miss the 'obvious' clue, "-i"! :-). tar(1) also has a "-i"-like option, only is is called "w":
> Cause tar to print the action being taken, followed by the
> name of the file, then wait for the user's confirmation. If
> the user answers y, the action is performed. Any other
> input means "no".
> and,
> after the tar is created, how do I
> delete/upgrade the tar so that only one file1 exists.
As far as I know, that is not possible.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2002 05:41 AM
06-21-2002 05:41 AM
Re: newbie tar question!
tar wxvf /bill.tar /home/bill/file1
This is INTERACTIVE MODE - confirm before each action, just like ftp's "mget" function.
You can pull any file you please from your archive.
Part 2> It would be simplest to extract your old tar file, update the files in question, and create a new tar file from it.
Brian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2002 06:11 AM
06-21-2002 06:11 AM
Re: newbie tar question!
my archives that I'm archiving in a central repository are getting massive because of multiple same file inclusions.
I don't want to have to recreate my entire tar every time I make a simple modification. This literaly takes hours to complete.
Later,
Bill