Bacula-users

Re: [Bacula-users] Mini stupid how-to restore mark all .bak file

2009-01-15 12:15:14
Subject: Re: [Bacula-users] Mini stupid how-to restore mark all .bak file
From: Foo <bfoo33 AT yahoo.co DOT uk>
To: bacula-users AT lists.sourceforge DOT net
Date: Thu, 15 Jan 2009 17:59:26 +0100
On Tue, 13 Jan 2009 11:58:09 +0100, Bruno Friedmann <bruno AT ioda-net DOT ch>  
wrote:

> Sorry this seems stupid but when I enter in a restore
> I use the choice 3 ( list of jobids )
>
> get my / rebuild
> If I issue a find *.bak it find and list all what I want to mark and  
> restore (recurse also)
> but giving  a
> mark *.bak give  0 file marked
>
> help say mark dir/file to be restored recursively, wildcards allowed

The recursive behaviour is broken, as well as listing already marked files  
outside of the directory they are in, in every version I used so far (2.0  
- 2.4.3).

My workaround for this is:

- use 'list jobs' or 'list jobname="<jobname>" to find the jobid you need,  
use '@output /tmp/foo' then 'list files jobid=<nnn>', then '@output' to  
dump the file list to /tmp/foo
- on a single line (hopefully not munged by the list/by browsers):
grep ".bak " /tmp/foo | awk '{ gsub(/^\|\ |\ +\|$/,""); print }' | awk -F  
"/" '{ printf ("cd \""); for (i=1; i<NF; i++) printf ("%s/", $i); printf  
("\"\n"); print "mark \"" $NF "\"" }' >/tmp/foo2

Note the space behind the extension, this makes sure we only get files  
that end with this (so .bak.2 and similar will not be restored). The awks  
strip leading/trailing pipes and spaces, then strip off path (using '/' as  
separator), does a cd to the path, then marks the file (NF is number of  
fields on the line, $NF is last field).

- in bconsole do restore, during file selection do '@input /tmp/foo2' -  
this will dump the file we just created above resulting in a bunch of cd  
and mark statements executed by bconsole. Use estimate or count to see how  
many files you marked, should be the same as 'wc -l /tmp/foo2'.

With lots of files this is slow, it could be optimized to cd to a dir only  
once and use wildcards for marking instead of the full filename, but  
that's left up to the reader :)


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users