Backup goes to local disk
I have an external drive that I want to do backups to. Most times it goes great, other times the server gets real sloggy, and I do a 'df' and see I'm at 96% disk usage. What has occured is the disk failed to mount apparently, so the backup backs up to my local disk at /media/backups/
I have /media/backups in my /etc/fstab pointing to /dev/sdc1, but I think the external disk will sleep when not in use for long periods. How do I make sure /media/backups is REALLY going to the external drive and not my local drive? Is there anyway to sort of test it BEFORE I write umpteen gigs to my local hard drive?? Thank you anyone! |
This command will return a 1 if the filesystem is mounted, and a 0 if not:
Code:
df | grep -c sdc1 |
So can you help me out a bit? MY bash scripting skills are abysmal...
Here's what I have (I am basically doing an rsync each night): #!/bin/sh sdparm --command=start /dev/sdc1 umount /media/GoFlex mount /media/GoFlex rsync -a --stats --exclude=/var/opt/scalix/ql/s/archive/* /var/opt/scalix /media/GoFlex/rBack/ The first command tells the external HD to "spinup" or wake up. I then unmount it (not sure why), then mount it. I then start the rsync. I suppose, looking at this, I should have specified the dev in my mount string, that might have avoided any unnecessary unpleasantries. But I would sure love to incorporate your little "check /dev/sdc1", "returns 0", "cancel backup" routine.... |
Is this the script you're already using, or are you starting work on this new? Because it seems to me that if you're already issuing a mount command before the rsync, then there might be something else going on here. In order to put this script together correctly, we need to identify the right state the filesystem will be in, and the right recovery method.
Assuming this is a new script you're working on, and that a mount is the correct response... Code:
#!/bin/bash At any rate, this gives you an idea of how to code the test, so you've got something to play with. |
Now, if you just want to get out of the script if it's not mounted...
Code:
#!/bin/bash |
There is also the command mountpoint which does the check directly.
|
Thanks SL00B, I think what you gave me is exactly what I need!
|
All times are GMT -5. The time now is 12:08 PM. |