I want to sync an USB drive with a folder located on a NTFS partition which is not mounted at boot time. I have found a command to do that: rsync -axu /media/USB/folder /home/user/folder. But I have to have the NTFS drive already mounted.
How can I detect if a NTFS drive is mounted or not from a script and if is not to mount it? I use Linux (Ubuntu).
This is the little script modified (the original is here) with your help!
#!/bin/bash
## CONFIG SECTION
MOUNT_DRIVE=/dev/disk/by-id/scsi-SATA_Hitachi_HTS5416_SB3404GRGJRKBS-part5
MOUNT_POINT=/media/Windows/
# Local folder to sync with
SYNC_LOC=/media/Windows/vasia/Disertatie/
# Device folder to sync with
SYNC_DEV=Disertatie
#
## SCRIPT SECTION
#verify if the drives are mounted
if mount | grep -q "/media/Windows/"; then
#device is mounted
echo "Windows NTFS Drive is mounted!"
else
#device is not mounted,let's mount it
mount $MOUNT_DRIVE $MOUNT_POINT
fi
# Wait for thumbdrive to settle
sleep 10
# Synchronize thumbdrive with local
rsync -axu /media/DISK_IMG/${SYNC_DEV}/ ${SYNC_LOC}/
# Synchronize local with thumbdrive
#rsync -axu ${SYNC_LOC}/ /media/disk/${SYNC_DEV}/
# Inform user that synchronization is complete.
zenity --title "Thumbdrive Sync" \
--info --text "File synchronization complete."