Yes, that is the approach I suggested: Have two scripts for backup and restore ready. By executing them in different order you can achieve many effects. Guillermo helped to iron out the bugs in your scripts, therefore I'm not going into details. Just two hints on how to debug:
1. During initial phase, you can copy the commands in those scripts line-by-line into
the console and execute them. Checking the output and its effect.
2. Later you can change the first of the script to "#!/bin/sh -x" (without the quotes) and
run them. You'll see a longer report as the output. You can also collect it to a file by "./scriptname > scriptname.out" for example.
About the cron job:
> The cron is set as
> But I am getting a message from the cron:
> /bin/sh: -c: line 0: unexpected EOF while looking for matching `''
> /bin/sh: -c: line 1: syntax error: unexpected end of file
Sound suspicious to me. A crontab looks like this:
# crontab -l
2,22,42 * * * * /usr/bin/php /path/to/moodle1/admin/cron.php > /dev/null
3,23,43 * * * * /usr/bin/php /path/to/moodle2/admin/cli/cron.php
moodle1 is a Moodle 1.x, the output goes straight to the wastebasket.
moodle2 is a 2.x, the output is sent to the owner of the crontab, in this case the 'root'.
Once you have it running, repeat the exercise in Windows!
BTW, I had a similar idea, see "A testbed for Moodle" https://moodle.org/mod/forum/discuss.php?d=214084
in the "Testing and QA" forum.