12.1 Update: removed paths, added exclude, updated adb-sync
This commit is contained in:
parent
91a2ff01c3
commit
db67408ac9
7 changed files with 74 additions and 878 deletions
|
|
@ -1,35 +1,21 @@
|
|||
#!/bin/zsh
|
||||
# This script syncs an Android with a Mac using adb and adb-sync.
|
||||
# Version 9.5 (16 April 2019)
|
||||
|
||||
# The below are Platypus features for managing UI
|
||||
echo "DETAILS:HIDE" # Hides the deatiled text in progress bar
|
||||
echo "PROGRESS:0" # Show the progress bar at 0%
|
||||
echo "Script starting" # Show this message above the progress bar
|
||||
# Version 12.1 (09 June 2021)
|
||||
# Added excluding .DS_Store. Unfortunately can only exclude one file
|
||||
|
||||
# Export paths for use if the script is turned into an app using Platypus.
|
||||
export LC_ALL=en_US.UTF-8
|
||||
export LANG=en_US.UTF-8
|
||||
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/$"
|
||||
|
||||
# Set the path to the log file and destinations
|
||||
export LOG=~/Projects/Programming/push/mobisync/mobisync-log.txt # A tilde will not work within quote marks.
|
||||
export MEDIA=/sdcard/DCIM/Moment/
|
||||
export DOCUMENTS=/sdcard/Documents/
|
||||
export DOWNLOAD=/sdcard/Download/
|
||||
# Sets the local paths
|
||||
export LOG=~/Library/Logs/mobisync.log
|
||||
export DOWNLOADS=~/Downloads/
|
||||
export MAC_MUSIC=~/Music/
|
||||
export ANDROID_MUSIC=/sdcard/Music/
|
||||
export OCTOPUS=~/Documents/tentacles/
|
||||
export TENTACLES=/sdcard/.tentacles/
|
||||
export APPS=~/Backup/Apps/
|
||||
export RECOVERY=~/Backup/Recovery/
|
||||
export MOBILE=~/Backup/Mobile/
|
||||
export SIGNAL=~/Backup/Signal/
|
||||
export AUDIO=/sdcard/Record/
|
||||
|
||||
echo "NOTIFICATION:Syncing is starting..." # Send a notification (with logo)
|
||||
echo "PROGRESS:10"
|
||||
echo "Default paths set"
|
||||
# Set error variable
|
||||
ERROR=0
|
||||
|
||||
echo "NOTIFICATION: Sync is starting..." # Send a notification (with logo)
|
||||
|
||||
# Function: Reviews the last command for errors. Then prints update complete to log or shows error dialog. Takes section variable.
|
||||
catcher () {
|
||||
|
|
@ -37,9 +23,22 @@ if [ "$?" = "0" ]; then
|
|||
printf "$1 synced." >> $LOG # If no error, print sync complete to file.
|
||||
echo "" >> $LOG # Add a line to file.
|
||||
else # If error, show a dialog stating the section where the error occured.
|
||||
echo "NOTIFICATION:'$1' sync failed."
|
||||
echo "NOTIFICATION: '$1' sync failed."
|
||||
printf "$1 failed to sync." >> $LOG # If error, print sync failed to file.
|
||||
echo "" >> $LOG # Add a line to file.
|
||||
ERROR=1 # Sets variable for error in script to 1.
|
||||
fi
|
||||
}
|
||||
|
||||
# Function: If there has been an error in the script open the log file.
|
||||
verify () {
|
||||
if [ $ERROR = 1 ]; then
|
||||
{ echo "Error: Mobisync encountered an error in execution"; line; } >> $LOG
|
||||
open $LOG
|
||||
echo "NOTIFICATION: Syncing completed with some errors."
|
||||
else
|
||||
{ echo "Success: Mobisync completed successfully"; line; } >> $LOG
|
||||
echo "NOTIFICATION: Syncing is complete"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
@ -49,64 +48,44 @@ printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' - >> $LOG # Prints line
|
|||
}
|
||||
|
||||
# Writes the header for the log file: Program, Version number, Date and Line.
|
||||
{ echo "mobisync 9.5"; echo "Log: " `date`; line; } > $LOG
|
||||
{ echo "mobisync 12.1"; echo "Log: " `date`; line; } >> $LOG
|
||||
|
||||
# Syncing images / video on device to the Downloads folder and sync the wallpaper on computer.
|
||||
{ adb-sync --reverse $MEDIA $DOWNLOADS; } >> $LOG
|
||||
catcher Images
|
||||
line
|
||||
echo "PROGRESS:20"
|
||||
echo "Images synced"
|
||||
|
||||
# Syncing audio on device to the Downloads folder on computer. Audio is isolated to extension-type downloads only.
|
||||
{ adb-sync --reverse $AUDIO $DOWNLOADS; } >> $LOG
|
||||
catcher Audio
|
||||
line
|
||||
echo "PROGRESS:30"
|
||||
echo "Media synced"
|
||||
|
||||
# Syncing documents on device to the Downloads folder on computer.
|
||||
{ adb-sync --reverse $DOCUMENTS $DOWNLOADS; adb-sync --reverse $DOWNLOAD $DOWNLOADS; } >> $LOG
|
||||
catcher Documents
|
||||
line
|
||||
echo "PROGRESS:35"
|
||||
|
||||
# Syncing qSelf data on device to the Documents/qSelf folder on computer.
|
||||
{ adb-sync --reverse $TENTACLES $OCTOPUS; } >> $LOG
|
||||
catcher qSelf
|
||||
line
|
||||
echo "PROGRESS:40"
|
||||
echo "Documents synced"
|
||||
|
||||
# Syncing music on computer to the music on phone.
|
||||
adb-sync --delete $MAC_MUSIC $ANDROID_MUSIC >> $LOG
|
||||
# Syncing Music from the computer.
|
||||
{
|
||||
adb-sync --delete --exclude .DS_Store ~/Music/ "/sdcard/Music/";
|
||||
} >> $LOG
|
||||
catcher Music
|
||||
line
|
||||
echo "PROGRESS:50"
|
||||
echo "Music synced to phone"
|
||||
|
||||
# Syncing app, recovery and TWRP backups.
|
||||
{ adb-sync --reverse --delete /sdcard/Backup/Apps/ $APPS; adb-sync --reverse /sdcard/.Ota/ $RECOVERY; adb-sync --reverse --delete /sdcard/TWRP/Backups/75fbabd4/ $MOBILE; adb-sync --reverse --delete /sdcard/Signal/Backups/ $SIGNAL; } >> $LOG
|
||||
catcher Backups
|
||||
# Syncing documents on device to the Downloads folder on computer.
|
||||
{
|
||||
adb-sync --reverse --times "/sdcard/Documents/Checkin/" ~/Documents/Checkin/;
|
||||
adb-sync --reverse --times --delete "/sdcard/Documents/Logistics/" ~/Documents/Logistics/;
|
||||
adb-sync --exclude .DS_Store --delete ~/Documents/Papers.sparsebundle/ "/sdcard/Documents/Papers.sparsebundle/";
|
||||
adb-sync --reverse "/sdcard/Download/" $DOWNLOADS;
|
||||
} >> $LOG
|
||||
catcher Documents
|
||||
line
|
||||
echo "PROGRESS:70"
|
||||
echo "Mobile backups synced"
|
||||
|
||||
# Syncing system backups and recovery to phone.
|
||||
{ adb-sync --delete ~/Documents/Secure.sparsebundle /sdcard/Backup/System/; adb-sync --delete $RECOVERY /sdcard/Backup/Recovery/; } >> $LOG
|
||||
catcher System
|
||||
# Syncing Automate data on device to the computer.
|
||||
{
|
||||
adb-sync --two-way --exclude .DS_Store ~/Projects/Programming/push/automate/ "/sdcard/.automate/Interface/";
|
||||
adb-sync --reverse "/sdcard/.automate/" ~/Mobile/Automate/;
|
||||
} >> $LOG
|
||||
catcher Automate
|
||||
line
|
||||
echo "PROGRESS:80"
|
||||
echo "System backups synced"
|
||||
|
||||
# Deleting all synced media from phone.
|
||||
{ adb shell rm -rf '/sdcard/Record/*.mp3'; adb shell rm -rf '/sdcard/Movies/*'; adb shell rm -rf '/sdcard/DJI/Camera/*'; adb shell rm -rf '/sdcard/DCIM/*'; adb shell rm -rf '/sdcard/DCIM/.thumbnails/*'; adb shell rm -rf '/sdcard/Documents/*'; adb shell rm -rf '/sdcard/Download/*' } >> $LOG
|
||||
echo "PROGRESS:90"
|
||||
echo "Cleanup completed"
|
||||
# Syncing app, recovery and backups.
|
||||
{
|
||||
adb-sync --reverse "/sdcard/Restore/" ~/Mobile/Restore/;
|
||||
adb-sync --reverse --times "/sdcard/Backup/" ~/Mobile/Backup/;
|
||||
} >> $LOG
|
||||
catcher Backup
|
||||
line
|
||||
|
||||
# Notification that the sync is over.
|
||||
printf "Syncing is complete. END" >> $LOG
|
||||
echo "PROGRESS:100"
|
||||
echo "NOTIFICATION:Syncing is complete"
|
||||
line
|
||||
verify $ERROR
|
||||
|
||||
echo "QUITAPP"
|
||||
echo "QUITAPP"
|
||||
Reference in a new issue