local-bin/common/mobile

38 lines
840 B
Plaintext
Raw Normal View History

2020-07-25 10:45:44 +03:00
#!/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