Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
#!/usr/bin/perl -w use strict; # This file clumsily extracts the DB's hidden in the iPhone backup files # Usage: perl -w bkupextract.pl /Users/flip/Library/Application\ Support/MobileSync/Backup/*/* my %seen; foreach my $filename (@ARGV) { # Slurp File Contents open(FILE, "<$filename") or die "Can't open $filename: $!"; my $data = do {local $/; binmode FILE; <FILE>}; close(FILE); # skip non-SQLite Files ($data =~ m|SQLite|) or next; # identify the file and use it to name the output my $type = ($data =~ m!([^/]*?)\.(sqlitedb|db)!) ? $1 : 'unknown'; $seen{$type}++; my $outfilename = sprintf "%s_%02d.db", $type, $seen{$type}; # Helpful progress report printf STDERR "%-60s to %-25s\n", $filename, $type, $outfilename; # dump the part between "SQLite format 3" and end # FIXME -- is there cruft at end? I don't know the SQLite format. Maybe you do? open(OUTFILE, ">$outfilename") or die "Can't open $outfilename: $!"; binmode OUTFILE; my $sqlitedb = $data; $sqlitedb =~ s/^(.*?SQLite format 3)/SQLite format 3/; print OUTFILE $sqlitedb; close(OUTFILE); }
This paste will be private.
From the Design Piracy series on my blog: