Difference between revisions of "Dbdump"

From WebOS Internals
Jump to navigation Jump to search
(New page: This is just a simple script that will find all .db3 or .db files and dump them to the /media/internal/dbdump directory as html so you can poke around easily to see if there's anything int...)
 
Line 1: Line 1:
This is just a simple script that will find all .db3 or .db files and dump them to the /media/internal/dbdump directory as html so you can poke around easily to see if there's anything interesting.
+
This is just a simple script that will find all .db3 or .db files and dump them to the /media/internal/dbdump directory as html so you can easily poke around to see if there's anything interesting.
  
 
<pre><nowiki>
 
<pre><nowiki>

Revision as of 11:01, 2 August 2009

This is just a simple script that will find all .db3 or .db files and dump them to the /media/internal/dbdump directory as html so you can easily poke around to see if there's anything interesting.

<nowiki>
#!/bin/ash

SQLITE3=/usr/bin/sqlite3
FOLDER=/media/internal/dbdump
INDEX=$FOLDER/index.html
DB=1

getTables() {
        $SQLITE3 $1 .tables
}

dumpTable() {
        db=$1
        tableName=$2
        fileName=$3
        $SQLITE3 $db <<EOF >> $fileName
.mode html
.header ON
.nullvalue --NULL--
select * from $tableName;
.exit
EOF
}

if [ -d $FOLDER ]
then
        rm -rf $FOLDER.bak
        mv $FOLDER $FOLDER.bak
fi

mkdir $FOLDER

files=`find / -name '*.db' -o -name '*.db3'`

cat <<EOF > $INDEX
<HTML><HEAD><TITLE>dbdump</TITLE></HEAD><BODY>
EOF

for db in $files
do
        echo "DB:$db"
        echo "
$db
    " >> $INDEX dbFolder=$FOLDER/db$DB dbIndex=$dbFolder/index.html mkdir $dbFolder echo "<HTML><HEAD><TITLE>dbdump - $db</TITLE></HEAD><BODY>Tables
      " > $dbIndex tables=`getTables $db` for table in $tables do echo " - $table" echo "
    • <A href='db$DB/$table.html'>$table</A>" >> $INDEX echo "
    • <A href='$table.html'>$table</A>" >> $dbIndex tablePage=$dbFolder/$table.html echo "<HTML><HEAD><TITLE>dbdump - $db/$table</TITLE></HEAD><BODY>" > $tablePage dumpTable $db $table $tablePage echo "
      </BODY></HTML>" >> $tablePage done echo "
    " >> $INDEX echo "
" >> $dbIndex echo "Generated: `date`" >> $dbIndex echo "</BODY></HTML>" >> $dbIndex DB=$(($DB+1)) done echo "Generated: `date`" >> $INDEX echo "</BODY></HTML>" >> $INDEX
<nowiki>