Adding mobile mount/unmount script
This commit is contained in:
parent
61f6c5d47a
commit
4ed78f8111
|
@ -0,0 +1,37 @@
|
|||
#!/bin/sh
|
||||
mobiroot="${HOME}/mobile/Internal shared storage"
|
||||
destroot="${HOME}/Backups"
|
||||
today=$(date +"%Y%m%d")
|
||||
backupdirs=("Books" "DCIM" "Conversations" "Documents" "Download" "Pictures" "Snapchat" "Telegram" "WhatsApp")
|
||||
|
||||
mobimount() {
|
||||
if [ ! -d "${mobiroot}" ]; then
|
||||
mkdir ~/mobile && jmtpfs ~/mobile
|
||||
else
|
||||
printf "Mobile is already mounted.\n"
|
||||
fi
|
||||
}
|
||||
mobiunmount() {
|
||||
if [ -d "${mobiroot}" ]; then
|
||||
fusermount -u ~/mobile && rm -r ~/mobile
|
||||
else
|
||||
printf "mobile is not mounted.\n"
|
||||
fi
|
||||
}
|
||||
mobibackup() {
|
||||
mobimount
|
||||
for dir in ${backupdirs[@]}
|
||||
do
|
||||
printf "Backing up ${dir}\n"
|
||||
mkdir -p ${destroot}/${today}/${dir}
|
||||
rsync -avz --exclude=".*" "${mobiroot}/${dir}" "${destroot}/${today}/"
|
||||
done
|
||||
}
|
||||
|
||||
if [ "$1" == "mount" ]; then
|
||||
mobimount
|
||||
elif [ "$1" == "unmount" ]; then
|
||||
mobiunmount
|
||||
elif [ "$1" == "backup" ]; then
|
||||
mobibackup
|
||||
fi
|
Loading…
Reference in New Issue