completed sync shell script (untested)