I have to do scheduled backup of servers' databases using a cronjob for the backup task and a bash script for the backup operation. It's a PHP web application. You can choose to store your backup file on the server hard disk or on an external USB flash drive or hard disk.
The user adds a backup task and edit it from the web page application designed to show all saved backup tasks with all their information :
server - database - tables - target server - target storage - day - hour - minute
All this is saved in an xml file and shown in a table. You can add, edit or delete a task from that table in that page.
USB drives should be auto-mounted on the remote servers and the PHP application should then tell the user when a drive is available for the saved tasks with target storage equals usb.
I have a bash script doing this but manually on one server at a time. I'm using CentOS on Virtual Box guests. My Virtual Box host is Ubuntu and I'm still a beginner. I need your help with commands.
I currently have a command that gets the name of usb (not its id) like this:
# Get USB stick count, name and size dec_count=`fdisk -l | tr -s ' ' | grep 'Disk /' -c` fdisk -l | tr -s ' ' | grep 'Disk /' | cut -f3 -d'/' | cut -f1 -d',' | sed -n "2,$dec_count p"
This is because I need a unique id for each USB drive, not the name that Linux gives it (like sdb).
Then, how can my PHP application know if there's a USB drive available? Should a cronjob do that or should it be done in PHP?
Am I taking this problem correctly? Any helping links or advises are so welcome. Need to do it fast.
Thanks in advance.