Hi all
I'm not really familiar with Linux syntax but can make out some of the stuff. I need help with a backup procedure that I want to get in place for a large company. Please advise if I'm using the correct method to backup data or not. If there is any other command line backup scripts that I can use, please let me know.
SCRIPT BELOW:
- I unmount the drives
- then format those devices
- then re-mount those drives
- and then copy data to the empty drives
Only one drive will be available at a time.
umount -l /dev/sdc1 /exusb
umount -l /dev/sdd1 /exusb
mkfs.ext3 /dev/sdc1
mkfs.ext3 /dev/sdd1
mount -t ext3 /dev/sdc1 /exusb
mount -t ext3 /dev/sdd1 /exusb
#check if the first drive is mounted or not
if grep -qs '/dev/sdc1' /exusb; then
cd /exusb
mkdir SGDatabase
time cp -dupvR /backup/SGDatabase /exusb/SGDatabase > SGDatabase_copy.txt
else
#check if the second drive is mounted or not
if grep -qs '/dev/sdd1' /exusb; then
cd /exusb
mkdir SGDatabase
time cp -dupvR /backup/SGDatabase /exusb/SGDatabase > SGDatabase_copy.txt
else
echo "Drives were not mounted"
fi
fi
When I run this script I get the following error, "syntax error near unexpected token `fi'." What could the possible reasons be for this?
When I add the following in the first line of the script file, "#!/bin/bash" I get a different error, "-bash: ./password.sh: /bin/bash^M: bad interpreter: No such file or directory." I'm not sure what this is. I have check the bin/bash directory and the file is there.
Any help will be much appreciated. Thank you
PS. I'm a Java and Php web application developer. This is my first shot at getting a backup solution for the client that runs CentOS with virtual environments and stuff like that.