Could someone please tell me why this script doesn't run correctly. Seems to be a problem with the if statement as i keep getting the error:
/home/sinttx/Development/backup/ddbackup.sh: line 18: syntax error near unexpected token `then'
/home/sinttx/Development/backup/ddbackup.sh: line 18: if [ "$exit" -eq 0 ] ; then'
The script:
#!/bin/bash
#(SINTTX) Function and if statement to backup/clone /dev/???.
echo "
THIS WILL COMPLETE A BACKUP OF DESIRED /DEV "
echo -n "Enter desired name for saved file (File will be saved with extention .iso) and press [ENTER]: "
read iso
echo -n "Enter the device to be duplicated/backed up (Eg /dev/sda) and press [ENTER]: "
read dev
echo -n "Enter the desired path/location for the backup file (Eg /home/USERNAME/backups/) and press [ENTER]: "
read path
echo "PLEASE ENTER THE SUDO PASSWORD (IF PROMPTED) AND WAIT :-)
NOTE: THIS COULD TAKE SOME TIME DEPENDING ON FILE SIZE AND HARDWARE SPEED!!"
sudo dd if="$dev" of="$path"/"$iso"
exit=$?
if [ "$exit" -eq 0 ] ; then
echo "SUCCESS"
else
echo "BACKUP HAS SUFFERED AN ERROR AND DID NOT COMPLETE SUCCESSFULLY"
fi
cat -v ddbackup.sh
.