Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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??
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
TEST=`df | grep -c sdc1`
sdparm --command=start /dev/sdc1
if [ $TEST = 0 ]; then
mount /media/GoFlex
fi
rsync -a --stats --exclude=/var/opt/scalix/ql/s/archive/* /var/opt/scalix /media/GoFlex/rBack/
I also have some question about whether the command to unsuspend the disk is placed correctly. If it's not mounted, and then you mount it... do you need to then unsuspend?
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
TEST=`df | grep -c sdc1`
sdparm --command=start /dev/sdc1
umount /media/GoFlex
mount /media/GoFlex
if [ $TEST = 0 ]; then
echo "Script aborted, fileystem not mounted." # This line assumes you're logging the output somewhere, omit otherwise.
exit
fi
rsync -a --stats --exclude=/var/opt/scalix/ql/s/archive/* /var/opt/scalix /media/GoFlex/rBack/
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.