2010/11/22 Kshitiz <kshitij_kotak(a)hotmail.com>om>:
Before running the rsync copying script, I want to
a) Add some statement that would check if the external harddisk is attached and
b) If not, it should be mounted before the copying script is run to copy only to this
c) If it is not mounted, mount should be attempted, and if it does not mount, rsync
copying command should not be executed.
All mounted filesystems have an entry in /proc/mounts. Your script can
take advantage of this.
if ! grep -q /backup /proc/mounts; then
if ! mount -t ext3 /dev/sdb1 /backup; then
exit 1; # Mount failed, bail out
# Regular stuff here