Busybox Data Backup and other functionality - G1 Android Development

I was wondering if there could be a collection of commands for mainly backing up data, so that those of us that can't figure out the programming could reap on all the benefits that all of you have made possible.
One easy to use database? Copy, paste, list name of files in a directory to start? Please?

Well, i'm not quite sure what data you want to back up (metadata? or actual file data?) but there is a lot you can do with combinations of the *nix shell commands and piping/redirecting. For example, if you wanted to create a list of installed user apps you might enter
Code:
ls -al /data/app > dir.txt
If you wanted to only list apps created by Koush, then you might modify that to
Code:
ls -al /data/app | grep "koushikdutta" > koushapps.txt
There are many more commands and an infinite number of ways to combine them. To list them all would require a very long posting indeed.

O i c
I didn't realize it was that complicated. So basically I have to look through the extensive list of commands and try to piece together commands that will work for what I want?
Basically I am trying to copy apps. I saw that astro has a method of doing it, but being that the the phone has been hooked up with the functionality I figured I would try and get the hang of it.
Thanks for the info.

Ssantos6981 said:
I didn't realize it was that complicated. So basically I have to look through the extensive list of commands and try to piece together commands that will work for what I want?
Basically I am trying to copy apps. I saw that astro has a method of doing it, but being that the the phone has been hooked up with the functionality I figured I would try and get the hang of it.
Thanks for the info.
Click to expand...
Click to collapse
Copying is pretty simple. Just cp <source> <destination>
So if you wanted to copy all the userapps made by Koush to sdcard, you could use
Code:
cp /data/app/*koush* /sdcard/
Once you get the hang of working with the basic shell commands and stringing them together in useful ways, you can save it all into a script file and just execute that whenever you want to perform a task.
For example you might have a small script that copies all the com.koushikdutta apps from the data partition to a backup folder in the sdcard, create a manifest containing a list of those apps along with their MD5 checksums, and then display onscreen how many megabytes were copied.
You can get pretty far just reading tutorials on the internet, but I recommend getting a primer from your local library or bookstore on *nix shell command and shell scripting. Also finding your local linux user group could help as well.

Related

Backing up apps / data (plus archiving/restore idea)

Ok, even though I have market and browser cache being saved to my sdcard, I still occasionally run into space issues due to the small /data partition. Prior to removing apps, I decided to back up my apps and data.
I have backed up my data partition using:
busybox tar -cvf /sdcard/data_backup_20081206.tar /data
After saving a copy to my computer via USB, I did MD5 checksum checks to make sure no corruption during the copy. I still need to do tests to see if I ever have corruption based on the thread in this forum.
* Anyone else making backups using other methods (rsync, etc.)?
--------------------------------------
This got me thinking to some other phone OS's that don't really run apps from SDCARDS, but rather store them and copy them to the phone prior to running them.
I would think that we could (with root access) write an app that moves files from the /data folders to a /sdcard/dataarchive folder, when you wanted to archive an app you don't use much and wanted to save space. Then the Archiver app could restore the files when you eventually wanted to run the app.
* Is there an easy way to see what files are used by each app? Someone mentioned a manifest file at one point.
For example, it looks like neocore is at minimum using:
/data/dalvik-cache/[email protected]@[email protected]
/data/app/com.qualcomm.qx.neocore.apk
/data/data/com.qualcomm.qx.neocore
* Is there a thread someone could point me to that better explains the whole APK packaging and storage of applications and their data?
** Is the structure usually just as above, except just replacing com.qualcomm.qx.neocore with the proper app name?
** When do things get saved to app-private?
O' great community... thanks for your help.
-oldsk00lz
i was looking for a way to synch my /Music and my /Pictures so I came across this blog. im mounting the g1's sdcard on a linux machine in this scenario
http://philnelson.name/tag/rsync/
heres my script that i use. hope this helps a little.
Code:
#!/bin/bash
echo "Syncing /Music /media/FC30-3DA9/Music for updates to /media/E0E4-AA14................................................................."
rsync -rvv /media/FC30-3DA9/Music /media/E0E4-AA14
echo "Syncing /Music /media/E0E4-AA14 for updates to /media/FC30-3DA9/Music................................................................."
rsync -rvv /media/E0E4-AA14/Music /media/FC30-3DA
echo "Syncing /Music /media/E0E4-AA14 for updates to /media/FC30-3DA9/Music................................................................."
rsync -rvv /media/E0E4-AA14/dcim /media/FC30-3DA9/Pictures/g1Cam

new scripts

Please emal me at if you have a problem.
Thank you alritewhadeva with chmod
Cp the files to /system/bin.
Then chmod 755 (filenames)
Cleartmp
Clears all files in a chosen directory in a certain amount of days. You can chose the directory and the amount days.
Rename
You can rename all files or selected files.
Rmemptydir
Remove empty directories
Search
Search for files and folders
Grepcat
Is like a combination of egrep and cat.
My version of appstosd
There will be a folder in your sdcard called apps(MK47) and it has all your app from the market(free and also paid). This is good for when you wipe your Dream.
here is the scripts.
Might want to update your OP with the attachment and bold the commands so its easier to read Nice work
mohsinkhan47 said:
Please emal me at [email protected] if you have a problem.
Thank you alritewhadeva with chmod
Cp the files to /system/bin.
Then chmod 755 (filenames)
Cleartmp
Clears all files in a chosen directory in a certain amount of days. You can chose the directory and the amount days.
Rename
You can rename all files or selected files.
Rmemptydir
Remove empty directories
Search
Search for files and folders
Grepcat
Is like a combination of egrep and cat.
Click to expand...
Click to collapse
this can come in handy for the hero roms if u use the facebook feature quite often under the people app. i know i tend to show people certain pics of me or friends and it just eats up internal memory. all i do is clear the cache but if i can use this script to do so it'd save me that lil bit of hassle i have to go thru myself, appreciate the script, just curious tho... anyone know where to find where the albums cache is stored? i kno how to brose thru folders but i much rather have somebody that KNOWS rather than me THINKING i know... lol thanks in advance.
Thanks for the scripts. Can you repost the appstosd? The one you posted was empty.
cx92001 said:
Thanks for the scripts. Can you repost the appstosd? The one you posted was empty.
Click to expand...
Click to collapse
I won't be on a computer until Saturday so gtalk to me at
[email protected] invte me and I will give u the app2sd
I can't reach the clutch..
Hi,
I've been looking for a shell search tool for my SE Xperia X10 Android 1.6 phone to search the file system, and this has been the only resource I have found thus far. I have managed to download and copy the scripts to my Android device, but I am unsure on how to execute the .asc scripts on the Android shell.
I was unable to adb push the file to \system\bin. I pushed the file to \data but even mounting the system volume as RW I am unable to mv the scripts to the \system\bin folder.
adb shell
$ su
# mount -o remount,rw /dev/mtdblock3 /system
# mv /data/searh.asc /system/bin
mv /data/searh.asc /system/bin
failed on '/data/searh.asc' - Cross-device link
I tried running the chmod 755 search.asc command anyway, and execute it using ./search.asc, but receive the message:
basename: not found
getopt: not found
[: not found
shift: can't shift that many
Edit: I have now tried this in recovery mode and mounting the /system folder with RW permissions, still no joy.
Could someone please clarify what is required to get these scripts to operate?
I have only dabbled in linux so I am most likely missing something fundamentally obvious here.
Temp-n00b-usr
I managed to find a work around.
I was attempting to locate the Creatouch.apk which was not in /system/app or /data/app. It was infact in /data/app-private. I have manged to pull the .apk for a backup and removed this from the phone now.
I just used the file explorer in Droid Screencast to locate the file by browsing the system.
It would still be handy to be able to search the file system from a PC environment however.

Question about adding stock apps back

I have read and still don't understand how to add back apps like Sprint TV. I have them all saved on my computer I just do not know the commands to get them back into the phone. Do the apps I want to ad back need to be in a certain dir on my computer first. If someone could explain or either point me to a thread that explains this I would really appriciate it.
Seems I found an easy way to add sprints, htc's apps back into the phone once removed. I saved all of them on my computer and used HTC Sync to install the app back. I removed Nscar as a test using root manager, rebooted and it was gone, then opened up HTC synch and added it back. Not sure how to get the odex files back in but it works with apk files.
AFter testing it om HTCfootprints it would not install this. Installed Nscar with no problems.
I am also trying to figure out how to add sprint tv back onto my Hero. I see that people are saying to use adb push, but I can't seem to get it to work. I just rooted with the new fresh rom and everything is great, I just want to add back sprint tv. Any help would be appreciated, thanks
Im a total noob, but I got it the apps back on this way:
Go to the directory where the ADK Tools directory is. Then the following commands:
adb shell
su
mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
chmod 777 /system
chmod 777 /system/app
exit
exit
Then I copied the .apk files that I wanted to push to the tools directory
I am in.
Then did this:
adb push Sprint_TV.apk /system/app
I found it is case sensitive, so make sure you type the filename exactly.
I rebooted my phone and the apps (such as Sprint TV) were back.
I hope this helps, like I said, I spent an hour trying to figure it out, but this worked for me.
I would not recommend doing a chmod 777 on your system or app directory. Not that anything bad will necessarily happen, but it's generally not a good idea to mess with system file permissions when you don't have to.
Your procedure would work fine without those commands at all, in fact. You don't even need to enter the shell; just adb remount and then adb push.
those instructions worked perfectly. Thanks a ton.
I tried this with HtcFootprints. I removed the widget as well. When I added all 4 back in I can see the widget for footprints, but the footprint icon does not show up in the apps section.
Another thing of intrest. When I added Nscar back using HTC Sync, it now shows up as a third party app. It is no longer a system app and I can uninstall it like a market app.
Ok scratch that I did the Footprints again and the Icon is now there Thanks a Ton
I was able to push HtcTwitter.apk and .odex. i cannot get the widget to show up in the add HTC widgets menu. Any ideas?
Well, after trying my hand at update/rom modding with some success... I'm willing to take a shot at making update.zip files to easily flash individual stock apps back onto your phone. That's if there's any interest.
obelisk79 said:
Well, after trying my hand at update/rom modding with some success... I'm willing to take a shot at making update.zip files to easily flash individual stock apps back onto your phone. That's if there's any interest.
Click to expand...
Click to collapse
That would be great and very helpful to many
Easy Peasy App Install
I just copied the files to my SD card. I then browsed to the SD card folder using Linda File Manager and "clicked" the file. It asked me if I wanted to use Linda File Manager or Package Installer. I selected Package Installer and it proceeded to installed the package for me. Not need to get into the console or use any commands.
VOILA!

[Q] EEE - how to dump everything?

I don't know if ADB is even the best tool to do this, but I want to be able to copy the entire file system off the EEE pad onto a pc. I want everything, starting from the "/" root directory. I want the entire file system and all files copied over so I can work with them on the pc.
I have root (verified by # when entering adb shell and various root apps successfully running.)
My thought was to do "adb pull /" from a dos shell (running windows 7), but not everything copies over. I get lots of messages about "skipping special file", I dont get the /data/data directory, etc etc.
Is there a tool or some way to copy over the entire file system starting from "/" ?
Thank you.
Nvflash will let you download the APP partition which is the system folder. It's an ext4 filesystem that you can mount and poke around.
USP is the data partition.
Be careful not to format your TF!
Clockwork mod will backup the system.img and you can either mount or unyaffs this. I forget which one. Same for data.img
sent from my cyanogen(mod) vision
Is the data.img same as the USP partition? Is the system.img same as the APP partition?
which I can then mount and explore?
I don't want to edit anything, I only want to examine.
In particular, I want to take a snapshot of all the files and filesystem (directory structures, files, etc) before an app is run. After the app is run and exited, I want to take another snapshot and look at what has changed. If there are new files created, existing files edited, etc. I want to search for strings (grep), etc.
I was hoping I could copy all the files to do this, but perhaps there is another way like one of those you suggested (nvlash, clockwordmod, ??)
Thank you.
Nvflash and clockworkmod wouldn't be used on a running system. You might want to look in the /proc and caches, but I'm not an expert on this.
sent from my cyanogen(mod) vision
gee one said:
Nvflash and clockworkmod wouldn't be used on a running system. You might want to look in the /proc and caches, but I'm not an expert on this.
Click to expand...
Click to collapse
Expert or not, I really appreciate your advice.
I took your initial suggestion to be to use NVflash and/or clockworkmod to make backups of the device. It seems from some other threads I've read that the tablet drive consists of up to 15 or 16 partitions, two of which are USP and APP.
So conceivably I could back those up "before", and mount the backup images somewhere to look at, preferably on a pc.
Then, I could install and run the app in question, and use NvFlash and/or CWM again to make backup images, and look at them for comparison.
On another note, I tried installing busybox and running cp to move, for example, /data to the external SD card, but I think I need a bigger SD card.
I wonder if
busybox cp / /Removable/MicroSD/targetdirectory
would work to copy everything?
The danger with that is that some directories and files are virtual- /proc and I think /var are virtual directories. Files like dev/null dev/zero would be problematic!
You might want to do specific parts, such as /data, or even /data/data/your.app's.java.name.here
You could use "find ." and write a script to pull everything with adb, but it would take forever, so it might not be a true snapshot.
Have you looked at the ddms or some of the other tools in the android SDK?
Sorry to confuse. By snapshot I did not mean screenshot. I meant just a record of the state of the device at that point in time. Meaning, all the files before the app was run. Then all the files (any new ones, changes to existing ones, any deleted) AFTER the app was run. I want to look at what has changed.
Still, thanks for the ddms idea. I have to look at any other tools in the adb environment that could be useful.

[shell][utility][terminal] munky-tool

***MUNKY-TOOL***
IS AN ONBOARD ANDROID UTILITY
FEATURES
[*]Copy system.img
[*]Copy boot.img
[*]Backup efs
[*]Logcat
[*]Backup and Restore Contacts
[*]Out For A Rip
Munky-tool will locate and copy most partitions without you having to track down paths. This is convenient if you use a ROM kitchen, or just want to make a backup of your system without using custom recovery. Some devices do have weird partition names, and munky-tool will not find them. If this happens to you, run the following command in terminal emulator
Code:
ls /dev/block/platform/*/by-name
Paste the output and your device name in the comments, and I will work your device in if possible.
INSTRUCTIONS
Download zip or clone git
Place extracted munky-tool folder in system partition (must be able to set permissions)
Set permissions of munky-tool script (not the directory) to at least 775 (rwx rwx rw)
Open terminal emulator and key in 'su' for root permissions
cd to the munky-tool directory
Type ./munky-tool to execute the script and start the utility
​
DOWNLOAD
github
Dude once again you're creativity and hard work is paying off. Great job man
Style point for the rip bud!
Sounds very helpfull and as markbencze already replyed I gues it's working on the O+O too. Have to try it in the next days.
thx markbencze for sharing.
SaschaKH said:
Sounds very helpfull and as markbencze already replyed I gues it's working on the O+O too. Have to try it in the next days.
thx markbencze for sharing.
Click to expand...
Click to collapse
Yes. I tested it on my OPO. It went out for a rip. It will run on any device, and it will find the partitions on most.
Where's the download link dude, i'm not find download link from github ?
itsnie said:
Where's the download link dude, i'm not find download link from github ?
Click to expand...
Click to collapse
On the right side of page near the clone url, there should be a button that says download as zip.
Just realized you have to be in desktop view to see the download as zip button. I will post an additional link a little later.
Just added backup and restore contacts.
N-i-c-e!
Thank you.
I've been working on the same sort of thing, and trying to figure out how to get adb connected to the phone with debugging off, for those people (I won't use the word I'm thinking of) who don't make backups, then break the screen, or bootloop the phone. Your script makes finding the data partition trivial, but I'm still working on the "force debugging on from outside" part.
But munky is going to be part of my phone from now on.
Rukbat said:
N-i-c-e!
Thank you.
I've been working on the same sort of thing, and trying to figure out how to get adb connected to the phone with debugging off, for those people (I won't use the word I'm thinking of) who don't make backups, then break the screen, or bootloop the phone. Your script makes finding the data partition trivial, but I'm still working on the "force debugging on from outside" part.
But munky is going to be part of my phone from now on.
Click to expand...
Click to collapse
Thanks, man. Glad to hear you like it.
mike the inkman said:
***MUNKY-TOOL***
IS AN ONBOARD ANDROID UTILITY
FEATURES
[*]Copy system.img
[*]Copy boot.img
[*]Backup efs
[*]Logcat
[*]Backup and Restore Contacts
[*]Out For A Rip
Munky-tool will locate and copy most partitions without you having to track down paths. This is convenient if you use a ROM kitchen, or just want to make a backup of your system without using custom recovery. Some devices do have weird partition names, and munky-tool will not find them. If this happens to you, run the following command in terminal emulator
Code:
ls /dev/block/platform/*/by-name
Paste the output and your device name in the comments, and I will work your device in if possible.
INSTRUCTIONS
Download zip or clone git
Place extracted munky-tool folder in system partition (must be able to set permissions)
Set permissions of munky-tool script (not the directory) to at least 775 (rwx rwx rw)
Open terminal emulator and key in 'su' for root permissions
cd to the munky-tool directory
Type ./munky-tool to execute the script and start the utility
​
DOWNLOAD
github
Click to expand...
Click to collapse
Good Tool, do you already plan to support restore EFS? which make a full loop of running time change the EFS setting without a PC,
this can help to me to control the modem band preset selections for network testing purpose.
Azlun said:
Good Tool, do you already plan to support restore EFS? which make a full loop of running time change the EFS setting without a PC,
this can help to me to control the modem band preset selections for network testing purpose.
Click to expand...
Click to collapse
It is usually done in bootloader, but I am pretty sure I can make it work. Just need to test it before I release it. I am also going to release this as an apk soon. (Don't know how soon, but I probably won't have time for a few weeks)
An app that we can point new users to that will back up their userdata partition? Fantastic!
Rukbat said:
An app that we can point new users to that will back up their userdata partition? Fantastic!
Click to expand...
Click to collapse
Yeah, I think it will fill a need. I am going to do an APK to do the things from this script, and a corresponding GUI Linux package for APK modding, and maybe do something for Windows as I get time. In the process of moving somewhat unexpectedly, so it is taking longer than I would have liked.

Categories

Resources