From WebOS Internals
Note : this page/article is the chinese translation of the english wiki page : http://www.webos-internals.org/wiki/Application:SaveRestore
注意 : 本文章/页是一个英文维基页面的中文译本，原文在: http://www.webos-internals.org/wiki/Application:SaveRestore
Save/Restore 可以备份并还原应用程序的数据以及其他数据，比如某程序图标在启动器中的位置，这些都会从webOS设备的/media/internal/saverestore/目录（USB设备）还原。 这个应用程序的目标就是不需要再为了一点小事而去备份整个设备，并且在更换设备的时候能简单快捷地进行还原，就好象你根本就不需要还原一样。
|要想将你的应用程序数据备份到U盘，先点击"Save Application Data"，当进入保存页面的时候，你就可以选择想要备份的程序了。选择好之后，点击屏幕下方的"Save Selected"按钮。|
|当你想还原已备份数据时，点击主页面中的"Restore Application Data"， 然后选择你想还原的应用程序，最后点击"Restore Selected"按钮。|
最新的信息请查看Save/Restore中的 "Supported Applications" 列表。
- 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 )
- Palm SDK - (SDK Download - Palm Developer Center)
- access to the webOS command prompt
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:
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)
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
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:
/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)
#!/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:
SRCDIR="$APPDIR/sample" FILES=" facebook.dat pref.dat" source `dirname $0`/srf.app.filesFor the Database:
source `dirname $0`/srf.app.databasesFor the cookies:
source `dirname $0`/srf.app.cookiesThen always end with:
exit 0 :So, the final script would look like :
#!/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:
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
chmod ugo+x /var/svc/org.webosinternals.saverestore/com.palm.app.facebook
4) Then, first test out the code by typing:
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”
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”
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.
Post the script in the PreCentral SaveRestore thread so it can added 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.
See the Preware description for the changelog.