Jeff Abrahamson on Tue, 8 Oct 2002 15:40:04 -0400


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] j-pilot backups


On Mon, Oct 07, 2002 at 09:00:20AM -0400, Arthur S. Alexion wrote:
> On Monday 07 October 2002 07:01 am, Jeff Abrahamson wrote:
> > I do a text dump of my palm db's nightly, too, so I can just diff
> > two days' worth if I'm looking for a change.
> 
> How do you do the text dump?  (as opposed to backing up the PDBs?)

I've attached the perl script.

-- 
 Jeff

 Jeff Abrahamson  <http://www.purple.com/jeff/>
#!/usr/bin/perl -w

use strict;
use Palm::PDB;
use Palm::Address;
use Palm::Datebook;
use Palm::Memo;
use Palm::ToDo;


my $jpdir;
if(defined($ARGV[0]) and -d $ARGV[0]) {
    $jpdir = $ARGV[0];
    $jpdir .= '/' if($jpdir !~ m|/$|);
} else {
    $jpdir = $ENV{'HOME'} . "/.jpilot/";
}



&main();



sub main {

    &do_addresses();
    &do_datebook();
    &do_memo();
    &do_todo();
    return;
}



sub do_addresses {

    my $pdb = new Palm::PDB;
    $pdb->Load($jpdir . "AddressDB.pdb");
    
    for my $record (sort @{$pdb->{records}}) {
	my $str = $pdb->{appinfo}{categories}->[$record->{'category'}]{'name'};
	for my $key (keys %{$record->{fields}}) {
	    $str .= "  $key " . $record->{fields}{$key};
	}
	$str =~ s/\n/  /sg;
	print "[Address] $str\n";
    }

}



sub do_datebook {

    my $pdb = new Palm::PDB;
    $pdb->Load($jpdir . "DatebookDB.pdb");

    for my $record (sort @{$pdb->{records}}) {
	my $str = $record->{day} . "-" . $record->{month};
	$str .= "-" .  $record->{year};
	if($record->{start_hour} != 255) {
	    # Only output if defined, which is non-255
	    $str .= "  " . $record->{start_hour} . ":" . $record->{start_minute};
	    $str .= " - " . $record->{end_hour} . ":" . $record->{end_minute};
	}
	# Should indicate alarm or repeat info here
	if(defined($record->{description})) {
	    $str .= "  " . $record->{description};
	}
	
	my $note = "";
	if(defined($record->{note})) {
	    $note = $record->{note};
	}
	$str .= "  $note";
	$str =~ s/\n/  /sg;
	print "[Datebook] $str\n";
    }
}



sub do_memo {

    my $pdb = new Palm::PDB;
    $pdb->Load($jpdir . "MemoDB.pdb");

    for my $record (sort @{$pdb->{records}}) {
	my $str = $record->{data};
	$str =~ s/\n/  /sg;
	print "[Memo] $str\n";
    }
}



sub do_todo {

    my $pdb = new Palm::PDB;
    $pdb->Load($jpdir . "ToDoDB.pdb");

    for my $record (sort @{$pdb->{records}}) {
	my $str = "[" . $record->{priority} . "] ";
	if(defined($record->{due_day})) {
	    $str .= $record->{due_day} . "-" . $record->{due_month};
	    $str .= "-" . $record->{due_year};
	}
	$str .= " completed" if defined($record->{completed});
	$str .= $record->{description};

	my $note = "";
	if(defined($record->{note})) {
	    $note = $record->{note};
	    $note =~ s/\n/  /sg;
	}
	$str .= $note;
	print "[ToDo] $str\n";
    }
}