-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdb_cmp.sh
34 lines (29 loc) · 1.01 KB
/
db_cmp.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
# Compares two sqlite3 database files.
if [ 2 != $# ]
then
echo "Incorrect number of arguments format !!"
echo "Usage : ./db_cmp.sh.sh <Path of backup_database> <Path of new database>"
exit 1
fi
tables_1=`sqlite3 -line $1 ".table"`
rm -rf .1.dump 2> /dev/null
for current_table_1 in $tables_1
do
echo " Table Name :::::: $current_table_1" >> .1.dump
echo "" >> .1.dump
sqlite3 -line $1 "select * from $current_table_1" >> .1.dump
done
tables_2=`sqlite3 -line $2 ".table"`
rm -rf .2.dump 2> /dev/null
for current_table_2 in $tables_1
do
echo " Table Name :::::: $current_table_2" >> .2.dump
echo "" >> .2.dump
sqlite3 -line $2 "select * from $current_table_2" >> .2.dump
done
rm -rf db.diff 2> /dev/null
diff -b .1.dump .2.dump > diff.txt
sdiff -b .1.dump .2.dump > sdiff.txt
echo "Please refer diff.txt to view the difference in 2 DB's !!"
echo "And for detailed diff...please refer sdiff.txt !!"