Add backup commands

This commit is contained in:
Andrew Miner
2017-07-10 20:10:33 -07:00
parent 518f1067c3
commit dc81e990f1
6 changed files with 122 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
#!/bin/bash
function die {
echo $*; exit 1
}
LOCAL_MOUNT="$HOME/.backup-drive"
HOST=$(security find-generic-password -a $USER -s backup-host -w)
SHARE=$(security find-generic-password -a $USER -s backup-share -w)
USERNAME=$(security find-generic-password -a $USER -s backup-username -w)
PASSWORD=$(security find-generic-password -a $USER -s backup-password -w)
DRIVE="afp://$USERNAME:$PASSWORD@$HOST/$SHARE"
if ! mount | grep -q "$HOME/$LOCAL_MOUNT"; then
if [[ -e "$LOCAL_MOUNT" ]]; then
rm -rf "$LOCAL_MOUNT" || die "Could not mount to $LOCAL_MOUNT"
fi
mkdir -p "$LOCAL_MOUNT"
mount -t afp "$DRIVE" "$LOCAL_MOUNT" || die "Could not mount from $DRIVE"
fi