I have a script that I wrote and I need it extended,
I need the script to compare a directory list to a user variable if the directory does not exist then it needs to be created.
Then the users remote directory gets mounted (there are multiple users)
then an rsync takes place.
Please notice how I create the directories daily by date!
Your job is to fix up this script, I got the script to compare usernames by the number of letters and thats wrong.
so i need a spot to enter the mount points as well and to get the script to compare and care directories.
my budget is $30
#!/bin/bash
users=( ysapir david rpril zrobinson )
emailadd=
hostname=`hostname`
directory=`date +%Y-%m-%d`
echo ${users[@]}
echo $directory
foonum=${#users}
count=0
for d in $( ls /backup/ ); do
echo ${d[@]}
for ((i=0;i<$foonum;i++)); do
if [ "${users[${i}]}" = "${d[@]}" ] ; then
echo ${users[${i}]} directory is synced
mount //[login to view URL] /mnt/${users[0]}/ -o username=ysapir,password=zublahzublah
rsync -av /mnt/ysapir/ /backup/${users[0]}/$directory | tee /tmp/[login to view URL]
cat /tmp/[login to view URL] | mail -s "$(date)"
cat /tmp/[login to view URL] >> /var/log/rsync/log
umount //[login to view URL]
let "count += 1"
fi
done
done
echo "COUNT: " . ${count}
echo "FOONUM: " . ${foonum}
if [ ${count} != ${foonum} ] ; then
echo Usernames are not synced, please verify variable.
else
echo Usernames are all synced.
fi