Hi guys,
I have a basic bash script which I use to rsync one external drive to another external drive. I'm concerned that my script may delete everything from my destination drive if the source drive hasn't mounted properly.
How can I include a condition to check whether my external hard-drive is mounted?
Code:
#!/bin/bash
# List files to wake up drives
cd /media/external
ls
cd /media/mirror
ls
# Synchronize external hard drive to mirror hard drive
sudo rsync -av --progress --delete --exclude .Trash* /media/external/ /media/mirror/
Both drives mounted (mount command):
Code:
/dev/sdc1 on /media/external type vfat (rw,uid=1000,gid=100,utf8,dmask=027,fmask=137)
/dev/sdd1 on /media/mirror type fuseblk (rw,nosuid,nodev,allow_other,blksize=4096)
Could I use awk to grab the third column and compare that to a string or something?
I'm running 9.04 x86 server edition.
Thanks!!
Bookmarks