3 # barrybkup version 0.1
5 # Copyright (C) 2008, ashley willis <barry@venamous.net>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 # or FITNESS FOR A PARTICULAR PURPOSE.
16 # See the GNU General Public License in the COPYING file at the
17 # root directory of this project for more details.
19 # backs up each DB in phone, or each DB given on command line,
20 # to file ~/.barry/backup/<PIN>/<PIN>-<DATE>-<TIME>.tar.gz
21 # (identical output as the barrybackup GUI).
23 `bcharge`; # inits phone
30 @list = `btool -t`; # gets list of databases
37 $pin[2] =~ s/^Using device \(PIN\): //;
41 $tmpdir =~ s/^.*\//\
/tmp\//;
50 elsif (s/ Database: 0x[\da-f][\da-f]? '//) {
52 ($db[$i], $records[$i]) = split(/' \(records: /);
53 $records[$i] =~ s/\)$//;
59 print "### $i $db[$i] ###\n";
60 $hex = `btool -n -d "$db[$i]"`;
61 #print "### CONVERTING ###\n";
63 #print "### DONE ###\n";
69 $date = `date +%Y%m%d-%H%M%S`;
71 $tgz = "$pin-$date.tar.gz"; # use PIN instead of "bb-"
73 #`tar zcf $tgz -C $tmpdir $dirs`;
76 `cd $tmpdir; tar zc $dirs > ~/.barry/backup/$pin/$tgz`;
77 #`cd $tmpdir; tar zc $dirs > $pwd/$tgz; cd -`;
82 mkdir("$tmpdir/$file");
83 $dirs .= "\"$file/\"* ";
86 @hex = split(/\n/, $data);
89 if (s/^Raw record dump for record: //) {
90 #($record) and close (OUT);
92 #open(OUT, ">$file/$record");
98 $out[$record] .= pack("H*", $_);
102 foreach $record (@out) {
105 $record =~ s/(^[\0-ΓΏ]{15})//;
108 @header = split(//, $header);
109 #$recType = $header[0] . $header[1];
110 #$length = $header[2] . $header[3];
111 #$u1 = $header[4] . $header[5] . $header[6];
112 $dbVersion = $header[7];
113 #$dbRecordHandler = $header[8] . $header[9];
114 $recordID = $header[10] . $header[11] . $header[12] . $header[13];
116 #print "$recType\t$length\t$u1\t$dbVersion\t$dbRecordHandler\t$recordID\t$u2\n";
117 $recordIDTXT = reverse(unpack ("h*", $recordID));
118 $recordIDTXT =~ s/^0+//;
119 ($recordIDTXT) or $recordIDTXT = "0";
120 $dbVersionTXT = unpack ("H*", reverse($dbVersion));
121 $dbVersionTXT =~ s/^0+//;
122 ($dbVersionTXT) or $dbVersionTXT = "0";
123 open(OUT
, ">$tmpdir/$file/$recordIDTXT $dbVersionTXT");