[prev in list] [next in list] [prev in thread] [next in thread] 

List:       bacula-users
Subject:    Re: [Bacula-users] Catalog MD5 not matching file MD5
From:       MI <mi.lists () alma ! ch>
Date:       2019-05-08 18:34:37
Message-ID: 03fd0098-a358-ea52-9aea-f0061a5e49b4 () alma ! ch
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


This is a reply to a message to this list, that was posted 9 years ago. 
Well, it's never too late, is it? :-)

While trying to find how the md5 in the Bacula database is encoded, all 
I found was this message by Rory Campbell-Lange who had the same 
question and only a part of the answer : 
https://sourceforge.net/p/bacula/mailman/message/25948484/

It turns out it's easy to convert between the usual md5 format and the 
base64 encoded version used in Bacula, so here is a short Perl script 
which does that conversion:

#!/usr/bin/perl

## Convert md5 checksums between the formats used by
## - standard md5sum utilities (eg. "d41d8cd98f00b204e9800998ecf8427e")
## - and the base64 encoded version used by Bacula (eg. "1B2M2Y8AsgTpgAmY7PhCfg")

my $VERSION = 0.1;

use strict;
use MIME::Base64;

$_ = shift;

unless ($_) {
	die "Usage: $0 md5_to_convert\n";
}

if ( /^[0-9a-f]{32}$/ ) {
	$_ = encode_base64(pack("H*", $_));
	s/=*$//;
	print;
}
elsif ( /^[0-9a-zA-Z\/+]{22}$/ ) {
	print unpack("H*", decode_base64($_)), "\n";
}
else {
	die "Doesn't look like an md5: '$_'\n";
}


> [Bacula-users] Catalog MD5 not matching file MD5
> From: Rory Campbell-Lange <rory@ca...> - 2010-08-14 11:15:59
>
> Sorry to be asking so many questions, again.
>
> I have the following catalog record for a file:
>
>     path: /backup/archive/datasnap0/etc/
>     file: wgetrc
>     md5 : 7rJlwjvesDfThOLanMuCog
>
> After restoring this file I have run md5, and I get:
>
>     eeb265c23bdeb037d384e2da9ccb82a2  wgetrc
>
> After reading the docs I understand that the catalog record is a base64
> encoding. However, running
>
>     openssl dgst -md5 archive/datasnap0/etc/wgetrc | awk '{print $2}' 
> | openssl enc -base64
>
> returns ZWViMjY1YzIzYmRlYjAzN2QzODRlMmRhOWNjYjgyYTIK
>
> How can I match the catalog md5 record to the restored file's md5?
>
> -- 
> Rory Campbell-Lange
> rory@...
>




[Attachment #5 (text/html)]

<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>This is a reply to a message to this list, that was posted 9
      years ago. Well, it's never too late, is it? :-)<br>
    </p>
    <p>While trying to find how the md5 in the Bacula database is
      encoded, all I found was this message by Rory Campbell-Lange who
      had the same question and only a part of the answer :
      <a class="moz-txt-link-freetext" \
href="https://sourceforge.net/p/bacula/mailman/message/25948484/">https://sourceforge.net/p/bacula/mailman/message/25948484/</a></p>
  <p>It turns out it's easy to convert between the usual md5 format
      and the base64 encoded version used in Bacula, so here is a short
      Perl script which does that conversion:</p>
    <p> </p>
    <pre>#!/usr/bin/perl

## Convert md5 checksums between the formats used by
## - standard md5sum utilities (eg. "d41d8cd98f00b204e9800998ecf8427e")
## - and the base64 encoded version used by Bacula (eg. "1B2M2Y8AsgTpgAmY7PhCfg")

my $VERSION = 0.1;

use strict;
use MIME::Base64;

$_ = shift;

unless ($_) {
	die "Usage: $0 md5_to_convert\n";
}

if ( /^[0-9a-f]{32}$/ ) {
	$_ = encode_base64(pack("H*", $_));
	s/=*$//;
	print;
}
elsif ( /^[0-9a-zA-Z\/+]{22}$/ ) {
	print unpack("H*", decode_base64($_)), "\n";
}
else {
	die "Doesn't look like an md5: '$_'\n";
}
</pre>
    <br>
    <blockquote type="cite">
      <p>[Bacula-users] Catalog MD5 not matching file MD5<br>
        From: Rory Campbell-Lange <a class="moz-txt-link-rfc2396E" \
href="mailto:rory@ca...">&lt;rory@ca...&gt;</a> - 2010-08-14  11:15:59<br>
        <br>
        Sorry to be asking so many questions, again.<br>
        <br>
        I have the following catalog record for a file:<br>
        <br>
            path: /backup/archive/datasnap0/etc/       <br>
            file: wgetrc  <br>
            md5 : 7rJlwjvesDfThOLanMuCog<br>
        <br>
        After restoring this file I have run md5, and I get:<br>
        <br>
            eeb265c23bdeb037d384e2da9ccb82a2  wgetrc<br>
        <br>
        After reading the docs I understand that the catalog record is a
        base64<br>
        encoding. However, running<br>
        <br>
            openssl dgst -md5 archive/datasnap0/etc/wgetrc | awk '{print
        $2}' | openssl enc -base64<br>
        <br>
        returns ZWViMjY1YzIzYmRlYjAzN2QzODRlMmRhOWNjYjgyYTIK<br>
        <br>
        How can I match the catalog md5 record to the restored file's
        md5?<br>
        <br>
        -- <br>
        Rory Campbell-Lange<br>
        rory@...<br>
      </p>
    </blockquote>
    <br>
    <p><br>
      <br>
    </p>
  </body>
</html>





_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic