Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # This program is free software; you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation; either version 2 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- # MA 02110-1301, USA.
- #
- #Script for autmatically synchronize alls apps and their data
- #to a specified path on your computer.
- #When you plug in your device, the script will start to pull
- #all apps and their data to your computer.
- #When you haven't set the path where it should be saved, the script
- #will ask you to set the path.
- #Note: You'll need USB-Debugging enabled and the "adb"-command in your
- #path variable.
- #You can put this script to your automatically starting apps and let
- #it run in terminal.
- scripthelp () {
- echo "Usage: $0 [OPTION]"
- echo -e "Options: \n\tNo option\tRun the script"
- echo -e "\t-c\t\tSet new value for path."
- echo -e "\t-r\t\tSet new value for path, then run the script."
- echo -e "\t-h\t\tView this help."
- exit 0
- }
- config () {
- echo "Q: Where should I put the apps and their data?"
- read path
- echo "$path" > ~/autosync/.config
- exit 0
- }
- configrun () {
- echo "Q: Where should I put the apps and their data?"
- read path
- echo "$path" > ~/autosync/.config
- }
- clear
- while getopts "crh" OPT
- do
- case $OPT in
- c) config;;
- r) configrun;;
- h) scripthelp;;
- *) echo "$0: Wrong option!"
- scripthelp;;
- esac
- done
- echo "I: Waiting for device to connect..."
- echo "I: Make soure USB-Debugging is enabled on your phone."
- adb devices >/dev/null 2>/dev/null
- while [ `adb devices|grep -c "device"` = "1" ]
- do
- sleep 5
- done
- if [ ! -f ~/autosync/.config ]
- then
- mkdir ~/autosync/ >/dev/null 2>/dev/null
- configrun
- if [ ! -d $path ]
- then
- mkdir $path >/dev/null 2>/dev/null
- fi
- fi
- echo "I: Starting the sync process..."
- echo "I: Please wait. This may take a while..."
- path=`cat ~/autosync/.config|head -1`
- date=`date +%d%m%y`
- data="${path}/${date}/data"
- app="${path}/${date}/app"
- mkdir "${path}/${date}" >/dev/null 2>/dev/null
- mkdir "$data" >/dev/null 2>/dev/null
- mkdir "$app" >/dev/null 2>/dev/null
- adb pull /data/data "$data" >/dev/null 2>/dev/null
- adb pull /data/app "$app" >/dev/null 2>/dev/null
- echo "I: Done. Things are stored in ${path}/${date}."
- echo "I: If you want to synch again, start the script again."
- echo "I: Exiting now..."
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement