running the below script I receive :
line 8: ((: i = 0 : syntax error: invalid arithmetic operator (error token is " ")
Any idea what is wrong? Can it be the I edit with text editor on an iMac? something to do maybe with a CR?
domains=( yourdomain.com yourdomain2.com )
sqldbs=( yourdb1 yourdb2 )
opath=$HOME/backup/
mysqlhost=mysqlhostname
username=mysqlusername
password=mysqlpassword
suffix=$(date +%m-%d-%Y)
for (( i = 0 ; i < ${#domains[@]} ; i++ ))
do
cpath=$opath${domains[$i]}
if [ -d $cpath ]
then
filler="just some action to prevent syntax error"
else
echo Creating $cpath
mkdir -p $cpath
fi
mysqldump -c -h $mysqlhost --user $username --password=$password ${sqldbs[$i]} > ${cpath}/${sqldbs[$i]}_$suffix.sql
done