Fixed missing done to close loop
Changed ionice -c3 to nice -n18 ionice -c2 -n7  since our kernal is old
Remove repeted dirname at the end
Correct if test statements, neater rsync, and other minor bugs