Difference between revisions of "Application:SaveRestore"
(→Writing a SaveRestore Script)
|Line 196:||Line 196:|
Revision as of 06:44, 29 August 2010
Save/Restore enables saving and restoring application data and misc. other things such as remembering icon placement in the launcher to and from the /media/internal/saverestore/ directory (USB drive) on a webOS device. The goal is to make the need to restore a device or switch devices as easy as possible by eliminating as much as possible dealing with each little thing to get back up and running as if you hadn't needed to restore.
Use Preware to install this application.
|Click on "Save Application Data" to start saving your application data to the USB drive. Once you are at the save page, you can choose which applications you would like to back up. When you have decided, tap the "Save Selected" button at the bottom of the screen.|
|If you need to restore your backed-up data, tap on "Restore Application Data" on the main page. Then, pick which applications you would like to restore. To restore the data, click on the "Restore Selected" button.|
Please see the "Supported Applications" list in Save/Restore for the latest information.
Writing a SaveRestore Script
Programs you will need: webOS Quick Install tofrodos (tofrodos: Convert text files to/from MSDOS/Windows/Unix (freeware) ) a database program, such as SQLite Database Browser.exe (SQLite Database Browser | Download SQLite Database Browser software for free at SourceForge.net ) you will need access to the webOS command prompt Palm SDK (SDK Download - Palm Developer Center ) I highly recommend using the Windows Command prompt to get there, and not use the command prompt from webOS QI.
Finally, I suggest you take a look at this site: git.webos-internals.org Git - applications/saverestore.git/tree - scripts/ and get familiar with some existing scripts (note that when writing scripts, you do NOT include the line #s on each script)
Once this is done, you are ready to get started.
1) Put your phone in Developer Mode, connect to the Computer, and select “Just Charge”
2) Load up webOS Quick Install
3) open up 2 windows command prompts (you can do this by clicking on “Start”, “Run” then type “cmd”, then do it again)
Now, here is what you need to do
1) Use the App you want to create the script for for a little while. If it’s a game, make sure you get through a few levels. If it’s an app, make sure you load it up and make some changes in the app
2) in one command prompt, type in “novacom -t open tty://” to get to the phone’s command prompt
3) in the other windows command prompt, change to the directory that you installed “tofrodos”
4) you need to figure out the App ID of the application that you are trying to create the script for. There are a few ways to do this, but the easiest is to open up the save/restore app, click on “install applications” and find the app and copy the App ID (e.g. Facebook = “com.palm.app.facebook”). You can also use webOS Quick Install's Device Management window
5) When you write a script, there are 4 types of saves that you may need:
- Files (Save specific files. Usually only used for PDK Apps)
- Databases (If any app saves a lot of user-entered data (vs games that may just keep your progress of what level you reached), it probably uses a Database)
- Query (but you will RARELY use the Query version)
6) To check to see if you need to save specific files, in the Phone’s command prompt window, you want to check the files in the apps directory. Using facebook as an example, type in:
Code: ls -l -r -t /media/cryptofs/apps/usr/palm/applications/com.palm.app.facebookThis will give you a listing of all files, the “-l” will give you DETAILED view, “-t” sorts in chronological order, and “-r” give you the newest file on the bottom. Look to see if anything was changed with a timestamp of when you last used the app. Note that sometimes, the app may have a subdirectory that you need to check. You can tell if something is a directory if the attributes have a “d” in the beginning. (E.g. “sample” below is a directory, “file” is not)
Code: drwxr-xr-x 2 root root 1024 Mar 19 19:58 sample -rw-r--r-- 1 root root 1482572 Mar 19 19:58 fileif there are more directories, you may need to look in them. E.g. in the “sample” directory above, you would then need to
Code: ls -l -r –t /media/cryptofs/apps/usr/palm/applications/com.palm.app.facebook/sampleand look to see there are any files in there you need. If there are files, mark down the DIRECTORY and ALL Files you need
7) To check to see if the app uses a Cookie or a database, the easiest way is to use webOS Quick Install, select “Tools” – “Receive File”, and get the following 2 files:
Code: /var/palm/data/Databases.db /var/palm/data/cookies.dbThen, open each one of these databases (with SQLite Database Browser) and do a search for the application to see if it has an entry. If it does, then you know you need to backup the database and/or the cookie
8) so, now you are ready to write your script. Lets assume its for facebook application. So, the name of the script will be “com.palm.app.facebook”
Each script will start off with the following (replace “Name of program” with the name of the program)
Code: #!/bin/sh APPID=`basename $0` APPNAME="NAME OF PROGRAM" source `dirname $0`/srf.app.infoLets assume that you have all 3 situations for your app (2 files: “facebook.dat and pref.dat”, in the “\sample” directory), database, and cookies.
For the file section:
Code: SRCDIR="$APPDIR/sample" FILES=" facebook.dat pref.dat" source `dirname $0`/srf.app.filesFor the Database:
Code: source `dirname $0`/srf.app.databasesFor the cookies:
Code: source `dirname $0`/srf.app.cookiesThen always end with:
Code: exit 0 :So, the final script would look like :
Code: #!/bin/sh APPID=`basename $0` APPNAME="NAME OF PROGRAM" source `dirname $0`/srf.app.info SRCDIR="$APPDIR/sample" FILES=" facebook.dat pref.dat" source `dirname $0`/srf.app.files source `dirname $0`/srf.app.databases source `dirname $0`/srf.app.cookies exit 0Note that if the there was NOT a “sample” subdirectory, you would just write: SRCDIR="$APPDIR"
Also, please make sure there is an extra “Hard Return” after “exit 0”
So, now you have a script. However, because of the way the Windows treats Line Endings is different than how Linux treats line endings, you need to do the following: 1) Copy the script to the directory that you have the “tofrodos” application. If windows added a “.txt” to the filename, make sure you remove that. Then, in the 2nd windows command prompt (the one where you changed to the “tofrodos” folder), you need to run the following command: “Fromdos scriptname”. So, for the example above:
Code: Fromdos com.palm.app.facebook
2) using webOS Quickinstall, select “Tools” – “Send File” and send this file to:
3) In the Linux command prompt, make sure you are in the root directory (just in case, you can write “cd /”) and then run the following command (using the facebook example) to make the file executable
Code: chmod ugo+x /var/svc/org.webosinternals.saverestore/com.palm.app.facebook
4) then, first test out the code by typing:
Code: sh -x /var/svc/org.webosinternals.saverestore/com.palm.app.facebook infowith the “info” tag, I use this just to make sure that the code can recognize the script. If you get anything other than “exit 0” at the end, something is wrong!
5) if the “info” works, try running a “save”
Code: sh -x /var/svc/org.webosinternals.saverestore/com.palm.app.facebook saveagain, if you see anything other than “exit 0” at the end, then something went wrong. It’s hard to tell you what went wrong without seeing it, but something went wrong
6) go into the app and make changes. Play some more, delete some items, etc 7) back at the command prompt, run the “restore”
Code: sh -x /var/svc/org.webosinternals.saverestore/com.palm.app.facebook restoreagain, if you see anything other than “exit 0” at the end, then something went wrong.
At this point, try loading up the app and see if it reset the app back to the “save” position. If it did NOT, then it could be an issue where the cookies were cached by the device and it just wasn’t updating. Close out of the app, run the “restore” command again, and then IMMEDIATELY do a Luna Restart. When it’s back on, open the app and see if it worked
If this worked, then try loading up the save/restore app on the device and make sure that the save and restore works that way, too.
Don’t forget to replace the “com.palm.app.facebook” name in the example above with your app name you need.
FINAL STEP (thanks Rod for the reminder): Post the script here so we can add it to the app!
Make sure your saved package list is up to date in preware before using save/restore so that it backs up you most recent installed package list if you are going to be using webOS doctor on your device or moving to a new device. You also may want to save a copy of the backup located on the /media/internal/ area (USB drive). If switching devices make sure to copy the backup and anything else from there before deactivating your old device.
WebOS Internals provides Save/Retore as is without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of Save/Restore is with you. Should Save/Restore prove defective, you assume the cost of all necessary servicing, repair or correction.
In no event will WebOS Internals or any other party be liable to you for damages, including any general, special, incidental or consequential damages arising out of the use or inability to use Save/Restore (including but not limited to loss of data or data being rendered inaccurate or losses sustained by you or third parties or a failure of Save/Restore to operate with any other programs).
The Memos and Messaging application data can not be restored at this time. Some restored items require a luna restart or reboot of the device for the changes from the restore to take effect.
No known bugs
See the Preware description for the changelog.