Amanda-Users

add option --occurrence to gnutar amrecover command [Was: Re: Problems accessing my new autoloader]

2007-11-23 04:32:16
Subject: add option --occurrence to gnutar amrecover command [Was: Re: Problems accessing my new autoloader]
From: Paul Bijnens <Paul.Bijnens AT xplanation DOT com>
To: Amanda List <amanda-users AT amanda DOT org>, Amanda Hackers <amanda-hackers AT amanda DOT org>
Date: Fri, 23 Nov 2007 10:26:11 +0100


On 2007-11-23 09:35, Francis Galiegue wrote:
Le Friday 23 November 2007 09:17:01 Marc Muehlfeld, vous avez écrit :
One additional info to my last mail (sorry. I just replied to the sender,
and not to the list, thats why I let it below):

5 Minutes after I send this mail, the silent amrecover finished it's work
and the files where recovered. But why does it take 45 minutes to restore
one 45kb file? On the tape were just 9.1 GB in 60 files, so it should be
finished fast. Also its a fast LTO3 drive connected to a fast Adaptec 29160
SCSI card


Tar will unroll ALL the archive to find your file. Not sure why it doesn't stop if it finds the file at the beginning/middle of the archive though.


Because a file can appear multiple times in a tar archive, and
the normal semantics says that it needs the last version, unless
specified on the command line.

In gnutar you may store files multiple times in an archive. e.g.
 $ gtar -cf /tmpk/multi.tar file1 file1 file1
 $ gtar -tf /tmp/multi.tar
and note the file appears 3 times.
You can even append to an existing archive:
 $ date > file1
 $ gtar -rf /tmp/multi.tar file1
and when you restore, you get last version only.
Or be more specific about a specific occurrence:
 $ gtar --occurrence=3 -tvf /tmp/multi.tar

Amanda will *not* store multiple files in a tar archive, and
we could add indeed the option  "--occurrence" (the default=1)
for extracting with amrecover and then, according to the info page,
gnutar will terminate without scanning to the end of the archive.

This could speed up the restore process considerably for the "few files"
restores, the most frequent requests.

So the default restore command would become:
   gtar --occurrence --numeric-owner --xpGvf - extractlist


Patch against 2.5.2p1: file recover-src/extract_list.c:

--- extract_list.c_ORIG 2007-11-23 10:17:22.000000000 +0100
+++ extract_list.c      2007-11-23 10:18:36.000000000 +0100
@@ -1773,7 +1773,7 @@
 #endif
     case IS_TAR:
     case IS_GNUTAR:
-        extra_params = 4;
+        extra_params = 5;
         break;
     case IS_SAMBA_TAR:
         extra_params = 3;
@@ -1824,6 +1824,7 @@
     case IS_TAR:
     case IS_GNUTAR:
        restore_args[j++] = stralloc("tar");
+ restore_args[j++] = stralloc("--occurrence"); /* do not scan the rest of the archive if file found once */
        restore_args[j++] = stralloc("--numeric-owner");
        restore_args[j++] = stralloc("-xpGvf");
        restore_args[j++] = stralloc("-");      /* data on stdin */


--
Paul Bijnens, xplanation Technology Services        Tel  +32 16 397.511
Technologielaan 21 bus 2, B-3001 Leuven, BELGIUM    Fax  +32 16 397.512
http://www.xplanation.com/          email:  Paul.Bijnens AT xplanation DOT com
***********************************************************************
* I think I've got the hang of it now:  exit, ^D, ^C, ^\, ^Z, ^Q, ^^, *
* F6, quit, ZZ, :q, :q!, M-Z, ^X^C, logoff, logout, close, bye, /bye, *
* stop, end, F3, ~., ^]c, +++ ATH, disconnect, halt,  abort,  hangup, *
* PF4, F20, ^X^X, :D::D, KJOB, F14-f-e, F8-e,  kill -1 $$,  shutdown, *
* init 0, kill -9 1, Alt-F4, Ctrl-Alt-Del, AltGr-NumLock, Stop-A, ... *
* ...  "Are you sure?"  ...   YES   ...   Phew ...   I'm out          *
***********************************************************************

<Prev in Thread] Current Thread [Next in Thread>