From 4ed78f811108847c5ab5ed712a61f38c5387abec Mon Sep 17 00:00:00 2001 From: Siina Mashek Date: Sat, 25 Jul 2020 10:45:44 +0300 Subject: [PATCH] Adding mobile mount/unmount script --- bin/mobile | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 bin/mobile diff --git a/bin/mobile b/bin/mobile new file mode 100755 index 0000000..0bd973e --- /dev/null +++ b/bin/mobile @@ -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