3 PATH
=/usr
/bin
:/usr
/sbin
:/bin
:/sbin
7 USR_DUMP
=".mode insert user\n.output user.sql"
8 CAL_DUMP
=".mode insert calendar\n.output calendar.sql"
10 function export_db
() {
11 echo -n 'Please enter name of database to export from: '
13 if [ ! -e "$DB" ]; then
14 echo $DB: File does not exist
18 echo -e $USR_DUMP > "$DIR/$USR"
19 sqlite3
-init "$DIR/$USR" "$DB" 'select * from user where id <> 1'
22 echo -e $CAL_DUMP > "$DIR/$CAL"
23 sqlite3
-init "$DIR/$CAL" "$DB" 'select * from calendar'
27 function import_db
() {
28 echo -n 'Please enter name of database to import into: '
30 if [ ! -e "$DB" ]; then
31 echo $DB: File does not exist
34 if [ ! -e "./$USR" ]; then
35 echo $USR: File does not exist
38 if [ ! -e "./$CAL" ]; then
39 echo $CAL: File does not exist
43 sqlite3
"$DB" < "./$USR"
44 sqlite3
"$DB" < "./$CAL"
46 echo -n "Delete files containing backup [y/N]: "
48 if [ ! -z "$DEL" ]; then
49 if [ "$DEL" = "y" -o "$DEL" = "Y" ]; then
56 if [ $UID -ne '0' ]; then
57 echo You must run this
script as root
64 echo Database was succesfully exported
65 echo You should now perform standard
install
66 echo and run this
script with
command import
71 echo Database was succesfully imported
75 echo -e "usage: $0 CMD\n
77 \texport\texport data from a database
78 \timport\timport data to a database"