webOS Nation Forums >  webOS apps and software >  webOS development > Backup and Restore (Ideas/Howto)
Backup and Restore (Ideas/Howto)

  Reply
 
LinkBack Thread Tools Display Modes
Old 09/29/2009, 04:45 PM   #1 (permalink)
Member
 
Join Date: Sep 2009
Posts: 141
Likes Received: 0
Thanks: 30
Thanked 41 Times in 22 Posts
Default Backup and Restore (Ideas/Howto)

Yes, its possible. This is a quick howto that i'd like to get some feedback, input and hopefully continually update to make it better and better. I'm NOT 100% sure its perfect... but it has worked for me when using and restore Method One.

There are 2 ways I've found to do a local backup, that does get contacts, messages, etc, etc... but they do require the Pre to be rooted and/or have Terminal.

One - Tar the databases
Two - Use sqlite3 to extract sql dumps

I've verified with Method One that it does work, Method Two is possible.. but not without alot more work

Both methods require this first:
Do a search for "Patch_webOS_Make_USB_Partition_Writable_via_SFTP" (I can't post links)
As it makes it ALOT easier for getting the backups off, when using as a USB Drive.

Method One Backup:

Create a file called backupall and place the following code in it
Code:
#!/bin/sh

# Date Stamp
DATELONG=`date +%Y-%m-%d_%Hh%Mm`
DATESHORT=`date +%Y-%m-%d`
# Back directory location e.g /backups
BACKUPDIR="/media/internal/backups"

mkdir $BACKUPDIR/$DATESHORT

tar czf $BACKUPDIR/$DATESHORT/_var_luna-$DATELONG.tar.gz /var/luna
Using Windows or Linux:
Place the file on the Pre USB

Using Pre Terminal or Putty:
Code:
mkdir /media/internal/backups
mv /media/internal/backupall /opt/bin/backupall
chmod +x /opt/bin/backupall
Done!

Using Pre Terminal or Putty, type the following to get a backup:
Code:
backupall
You will now see backups being created and dated in /media/internal/backups/

Method One Restore:

Create a file called restore.sh and place the following code in it
Code:
### BACKUP NEW DATA, FILES, LAUNCHPOINTS AND PREFERENCES
mv /var/luna/data/ /var/luna/data-old
mv /var/luna/files/ /var/luna/files-old
mv /var/luna/launchpoints/ /var/luna/launchpoints-old
mv /var/luna/preferences/ /var/luna/preferences-old

### EXTRACT OLD DATA, FILES, LAUNCHPOINTS AND PREFERENCES
tar -zxvf _var_luna.tar.gz

### RESTORE OLD DATA, FILES, LAUNCHPOINTS AND PREFERENCES
cp -r /media/internal/backups/restore/var/luna/* /var/luna/
Using Pre Terminal or Putty, type the following:
Code:
mkdir /media/internal/backups/restore
Using Windows or Linux:
Place the file restore.sh on the Pre USB in that restore directory
Copy the backup file that you want to restore to the same restore directory
Rename the backup file (Should look something like this _var_luna-2009-09-29_13h55m.tar.gz) to _var_luna.tar.gz

Using Pre Terminal or Putty, type the following:
Code:
sudo -i
mount -o remount,rw /
sh /media/internal/backups/restore/restore.sh
mount -o remount,ro /
reboot
If you want to clean the backups of the original data, and the files that you extracted
Using Pre Terminal or Putty, type the following:
Code:
rm -r /media/internal/backups/restore/var/
rm -r /var/luna/data-old
rm -r /var/luna/files-old
rm -r /var/luna/launchpoints-old
rm -r /var/luna/preferences-old
I'm just a hack at linux, so im pretty sure things could be done better or differently.. and I definately want to hear feedback.

Issues with Method One:
Don't backup a 1.1 and restore to a 1.2, it will cause issues due to the databases changing!!

Method Two Backup:

This doesn't have a walkthru, since im still playing around with it but here are some notes/ideas!

Do a search for "SQLite2009 Pro Enterprise Manager" and get that (I can't post links)
Pre's use a database called sqlite3

So if you grab some of the .db3 files, you can open and view data.

To find .db3 files, use the following command using Pre Terminal or Putty:
Code:
find / -name *.db3
You can also use commands mentioned on these two pages:
(Can't post links)
Search for: sqlite.html
Search for: sqlite_commands_and_general_usage.html

Using Pre Terminal or Putty, type the following:
Code:
sqlite3 /var/luna/data/dbdata/PalmDatabase.db3 'select * from com_palm_messaging_data_ChatThread' | awk '{printf "<tr><td>%s<td>%s\n",$1,$2 }' >> test.sql
echo '.dump' | sqlite3 /var/luna/data/dbdata/PalmDatabase.db3 | gzip -c >ex1.dump.gz
echo '.dump com_palm_messaging_data_ChatThread' | sqlite3 /var/luna/data/dbdata/PalmDatabase.db3 | gzip -c >ex1.dump.gz
echo 'select * from com_palm_messaging_data_ChatThread;' | sqlite3 /var/luna/data/dbdata/PalmDatabase.db3 | gzip -c >ex1.dump.gz
Todo:
Get cron working to backup daily, weekly, etc etc
Have someone clean up and write better/safer code
Figure out easy methods to use sqlite3 to export and import

Once again.. I'm NOT responsible if something bad happens!!
daventx is offline   Reply With Quote
Thanked By: loopybandnerd
Old 10/06/2009, 01:24 PM   #2 (permalink)
Member
 
jwdv22's Avatar
 
Join Date: Apr 2009
Posts: 127
Likes Received: 0
Thanks: 76
Thanked 13 Times in 11 Posts
Default

OK, so just my experience... I am not a linux noob, but I am a novice. Familar with command line interfaces since DOS....

I couldn't get the backupall file to run when I typed sh /opt/bin/backupall
I get errors on the blank lines, aka line 2, 8 and 10 I think.
However by just manually entering the lines into Putty I got the backup file and was able to copy it to Windows.
I have done 3 WebOSDoctor resets so I thought this would be a great way to keep a backup of all tweaks, apps, app settings, etc. So if I goof it again, then I don't have to go thru the hassle of installing all 20 tweaks and patches plus who knows how many other apps.
Many thanks...
Just to sum up, if I do a restore all the HomeBrew apps and tweaks will be there? But not mp3's and the like?
jwdv22 is offline   Reply With Quote
Old 10/06/2009, 01:35 PM   #3 (permalink)
Member
 
Join Date: Sep 2009
Posts: 141
Likes Received: 0
Thanks: 30
Thanked 41 Times in 22 Posts
Default

This mostly is for the data. Like messages, and contacts.. not apps or patches installed. I need to get around and revising this, to backup messages, contact, bookmarks, apps order on pages.. etc etc.. just havent had the time.

Did that help as an answer?
daventx is offline   Reply With Quote
Old 10/06/2009, 02:47 PM   #4 (permalink)
Member
 
jwdv22's Avatar
 
Join Date: Apr 2009
Posts: 127
Likes Received: 0
Thanks: 76
Thanked 13 Times in 11 Posts
Default

That answers it.

So this doesn't exactly help with all the apps.
Well thanks anyway. I will keep plugging away.
jwdv22 is offline   Reply With Quote
Old 11/20/2009, 08:16 AM   #5 (permalink)
Member
 
Join Date: Jun 2009
Posts: 47
Likes Received: 0
Thanks: 4
Thanked 11 Times in 3 Posts
Default

daventx, can you continue progress on this? I have some old backed up .db3 files from one time I had to run WebOSDoctor that I would like to figure out how to merge back into my current db3 file (SMS conversations, specifically). I will pay $$ for a solution, sounded like you were on the path.
optik678 is offline   Reply With Quote
Old 11/20/2009, 08:36 AM   #6 (permalink)
Member
 
Join Date: Sep 2009
Posts: 141
Likes Received: 0
Thanks: 30
Thanked 41 Times in 22 Posts
Default

i've attempted merging quite a few times, but always ran into issues. Even though the most obvious tables that contained the old messages were copied from one db3 to another, every time i'd get a new message after that the fit would hit the shan and the messages would start messing up. So there was obviously some lil piece that i was missing. I would recommend SQLlite manager for firefox or SQLlite 2009 pro for windows to get the data out of there, that at least gives you a text file to look at / search through with names.
daventx is offline   Reply With Quote
Old 11/20/2009, 11:34 AM   #7 (permalink)
Member
 
Join Date: Jun 2009
Posts: 47
Likes Received: 0
Thanks: 4
Thanked 11 Times in 3 Posts
Default

I already was able to take the old convo's out of the db. I have those put have never been able to merge them back into the current db. Unfortunately, I don't know SQL at all, so I can't even begin to delve into this. (the re-merging)

Last edited by optik678; 11/20/2009 at 11:37 AM. Reason: clarification
optik678 is offline   Reply With Quote
Old 11/20/2009, 12:02 PM   #8 (permalink)
Member
 
Join Date: Sep 2009
Posts: 141
Likes Received: 0
Thanks: 30
Thanked 41 Times in 22 Posts
Default

You can use the above listed tools to do the import. The issue is that to import the messages, you also have to import 3-4 other tables. They all link to each other. And even when i did import the 3-4 tables, as soon as i got a message from the person that i had reimported, all of the messages disappeared. I know it IS possible, it'll just take alot of patience.. which i didn't have at the time.

For anyone who is interested, these are the tables that i BELIEVE are all linked with messages:

com_palm_messaging_data_ChatThread
com_palm_messaging_data_ChatThread_com_palm_messaging_data_ChatThread_ContactChat_AddressChat
com_palm_messaging_data_ChatThread_com_palm_pim_FolderEntry_Chat_Messages
com_palm_pim_FolderEntry
com_palm_pim_Recipient
daventx is offline   Reply With Quote
Reply

 

Tags
backup, howto

Thread Tools
Display Modes



 


Content Relevant URLs by vBSEO 3.6.0