I need a backup to USB script with rotating drives
I have a bash script that uses rsync to backup data on a daily basis to a USB hard disk and it's been working fine because the USB drive is always connected, however, the volume of data we need to backup has grown and I've had to split it across 4 x 2TB drives set as 2 spanned drives internally.
The first set is called FS1 and the second FS2, which I mount into the following two folders and make them available to our network /srv/FS1 /srv/FS2 Both have 4TB capacity. What I am trying to achieve is to create an automated backup script that runs from a cron job which checks what USB drive is available, mounts it into a matching mount point based on its name, then runs a rsync based backup that matches the connected drives name and exits gracefully. I have created the mount point directories /media/USB_FS1 /media/USB_FS2 and I have 2 drives named USB_FS1 & USB_FS2 respectively. Mounting, rsyncing and umnounting the drives from a script, that I can do, but I can't get my head around the way to check for a drives presence first and exit gracefully if the drive is not connected, and of course what I would like to achieve with the 2 drives in rotation. What I need help with is the portion of the script that checks for a drives presence and mounts it, then continues to the rsync line that matches the connected drive and its mount point. Anybody care to lend a hand? I am running Linux Mint |
You can check the output or rtn code of the mount cmd
|
2 drive rotation: Do you mean that only one drive will be present at any time? If both drives are present, do you want to detect which was used most recently, and use the other?
|
MikeP check your e-mail from LQ...
|
Thanks for your replies.
@ chrism01 - Umm, ok, not quite sure what you mean by that. but I think I have a smattering of an idea. Do you mean like this? Code:
if ! mount | grep -q '/media/USB_FS1'; then @ Beryllos - only 1 drive will be connected at a time because the backups will be taken off-site and copied to another storage facility. Due to the cost of internet here, its very slow upload speed (768kbps) and the volume of data that needs to be backed up, this is the most effective solution we can muster, though we did consider leaving both drives plugged in and purchasing another two so we can do rotations at a slower rate. @ lleb - Can you please re-send, I recently changed my email address and hadn't updated it here. I just updated and verified the new email address with LQ. Please do accept my apologies Thank you |
sent again.
|
I would code it something like this:
Code:
drive_list="/media/USB_FS1 /media/USB_FS2 /media/USB_FS3" |
Quote:
Code:
if [ $number_of_drives_available -eq 0 ]; then |
All times are GMT -5. The time now is 03:56 AM. |