Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#4164 Restore does not work

open
Jamie Cameron
5
2014-12-17
2012-11-09
Robert Oschwald
No

Bacula 5.0.3 Server, Webmin 1.600.

After selecting the files to restore in the java applet and clicking "add", the job is submitted.
But it stops at "cd <path". No "add" or "mark" command is submitted by the module to Bacula director.

Example:

Starting restore of job test-job to client test.my.office-fd from storage File ..

restore client=testclient.my.office-fd jobid=13660 storage=File where="/tmp/bacula-restores"
Using Catalog "MyCatalog"
You have selected the following JobId: 13660

Building directory tree for JobId(s) 13660 ... +++++++++++++++++++++++++++++++++++++++++++++
1,461,420 files inserted into the tree.

You are now entering file selection mode where you add (mark) and
remove (unmark) files to be restored. No files are initially added, unless
you used the "all" keyword on the command line.
Enter "done" to leave this mode.

cwd is: /
$ cd "/baculatest/subdir/foo"
cwd is: /baculatest/subdir/foo
$

.. thats the last message received.

As you see, I got lots of files in the db, so it takes a while until the message is displayed. Could this be some timeout issue?
BTW: restore in bconsole with the same commands and an additional "mark" command works.

Discussion

  • The client name was replaced by "testclient.my.office-fd". There is a type in the "restore client=" line. Sorry. Should read the same client name as the one in the first line.

     
  • Jamie Cameron
    Jamie Cameron
    2012-11-10

    How many files did you select to restore?

     
  • Approx. 850, including subdirectories.

     
  • Jamie Cameron
    Jamie Cameron
    2012-11-11

    Does it make any difference if you selected fewer files (or just one) ?

     
  • I tested now with only one file. It doesn't make any difference. Restore does not work. "mark" command is not sent to the director.

    I also updated to bacula 5.2.12_x86_64 (on CentOS 5) due to a problem with BAT in Bacula 5.0.3. This also doesn't make any difference.

    It seems restore.cgi has a problem around line 97, where it waits for the response of the "cd" command.
    So I added the following debugs:

    # around line 104, added "command to execute" print statements to see what happens:
    elsif ($f =~ /^(.*)\/([^\/]+)\/?$/) {
    local ($fd, $ff) = ($1, $2);
    $fd ||= "/";
    print("command to execute: cd \"$fd\"\n");
    &sysprint($h->{'infh'}, "cd \"$fd\"\n");
    &wait_for($h->{'outfh'}, "\\\$");
    print $wait_for_input;

    print("command to execute: mark \"$ff\"\n");
    &sysprint($h->{'infh'}, "mark \"$ff\"\n");
    &wait_for($h->{'outfh'}, "\\\$");
    print $wait_for_input;
    }
    }
    print("command to execute: done\n");
    &sysprint($h->{'infh'}, "done\n");

    and got this output:

    You are now entering file selection mode where you add (mark) and
    remove (unmark) files to be restored. No files are initially added, unless
    you used the "all" keyword on the command line.
    Enter "done" to leave this mode.
    command to execute: cd "/xxx/yyy/zzz/foo"

    cwd is: /
    $command to execute: mark "xxxxx_spaces.sh"
    cd "/xxx/yyy/zzz/foo"
    cwd is: /xxx/yyy/zzz/foo/
    $command to execute: done

    as you see, the print output for the "mark" command comes before the cd command is executed and result for it is returned. I don't know if that is the main cause of the problem.

     
  • Here is the complete output from bconsole when performing the same restore manually:

    *restore client=sample.local-fd jobid=13660 storage=File
    Using Catalog "MyCatalog"
    You have selected the following JobId: 13660

    Building directory tree for JobId(s) 13660 ... +++++++++++++++++++++++++++++++++++++++++++++
    1,461,420 files inserted into the tree.

    You are now entering file selection mode where you add (mark) and
    remove (unmark) files to be restored. No files are initially added, unless
    you used the "all" keyword on the command line.
    Enter "done" to leave this mode.

    cwd is: /
    $ cd "/xxx/yyy/zzz/foo"
    cwd is: /xxx/yyy/zzz/foo/
    $ mark "xxxxx_spaces.sh"
    1 file marked.

    $ done
    Bootstrap records written to /var/spool/sample.local/bacula-dir.restore.16.bsr

    The job will require the following
    Volume(s) Storage(s) SD Device(s)
    ===========================================================================

    xxx-0199 File B2DDevice

    Volumes marked with "*" are online.

    1 file selected to be restored.

    The defined Restore Job resources are:
    1: RestoreClient1
    2: RestoreSample
    3: RestoreClient3
    4: RestoreTest
    Select Restore Job (1-4): 2

    Run Restore job
    JobName: RestoreSample
    Bootstrap: /var/spool/sample.local/bacula-dir.restore.17.bsr
    Where: /tmp/bacula-restores
    Replace: always
    FileSet: sample-files
    Backup Client: sample.loca-fd
    Restore Client: sample.loca-fd
    Storage: File
    When: 2012-11-12 10:32:40
    Catalog: MyCatalog
    Priority: 10
    Plugin Options: *None*
    OK to run? (yes/mod/no): yes
    Job queued. JobId=13723
    *

     
  • Additional info:

    The restore.cgi processes are not quit. Therefore, I must kill them manually.
    So it seems restore.cgi is waiting for response infinitely.

     
  • Jamie Cameron
    Jamie Cameron
    2012-11-12

    Ok, I think I see the issue now - Webmin isn't waiting for the first $ prompt before running cd.

    Try adding the following line :

    &wait_for($h->{'outfh'}, "\\\$");

    just before :

    foreach $f (@files) {

    And let me know how it goes.

     
  • It goes a little further now but stops then:

    restore client=sample.local-fd jobid=13713 storage=File
    Using Catalog "MyCatalog"
    You have selected the following JobId: 13713

    Building directory tree for JobId(s) 13713 ... ++++++++++++++++++++++++++++++++++++++++++++++++
    27,598 files inserted into the tree.

    You are now entering file selection mode where you add (mark) and
    remove (unmark) files to be restored. No files are initially added, unless
    you used the "all" keyword on the command line.
    Enter "done" to leave this mode.

    command to execute: cd "/xxx/yyy/zzz/foo"
    cd "/xxx/yyy/zzz/foo"
    cwd is: /xxx/yyy/zzz/foo
    $
    command to execute: mark "xxx.gz"
    mark "xxx.gz"
    1 file marked.
    $
    command to execute: done

    and there it waits again.

     
  • Ok figured out what this problem is.
    I have more than one restore template in my bacula-dir.conf file. Because of this, the next step is not starting the job but another question:

    The defined Restore Job resources are:
    1: RestoreClient1
    2: RestoreSample
    3: RestoreClient3
    4: RestoreTest
    Select Restore Job (1-4): 2

    I for now remarked the additional restore templates.
    Now it works!

     
  • As an enhancement to the restore.cgi script, we should check the file mark response. Currently, If the file to be restored does not exist, the script hangs. The 2 responses are:

    "1 file marked" for single file
    "x files marked." for directories with subfiles and directories.
    "No files marked." if not found

    Should I open another ticket for it?

     
  • Here is the diff for the fix:

    --- restore.cgi.org 2012-11-12 10:45:43.000000000 +0100
    +++ restore.cgi 2012-11-13 10:21:59.000000000 +0100
    @@ -89,6 +89,9 @@
    &job_error($text{'restore_ejobfiles'});
    }

    + # fix. See ticket 3585746
    + &wait_for($h->{'outfh'}, "\\\$");
    + print $wait_for_input;
    # Select the files
    foreach $f (@files) {
    $f = &unix_to_dos($f);