Yes, Narit. This script that I wrote will do a complete backup. This backup could then be reinstalled on any similar server. I use my backups to regularly install a copy of my production moodle into my experimental (MAMP) server, on my Mac.
Some parts of this script will need to be modified for your own server. I am providing mine as a (good) example. You would certainly need to modify some lines, for example, the line with a password.
I cannot provide a step-by-step instruction of how to modify this script. You just need to study and learn.
To use this script, it has to be somewhere (in a safe spot) on your server, and then it gets executed with a CRON job.
Appreciate that in these server/moodle systems, there is great flexibility about how the administrator wants to do things, which is why step-by-step instructions are difficult. How does one get from Chicago to New York City, or from Paris to Rome? Many many ways.
I should also mention a few more things. I run this script only once each day (during the early U.S. morning hours.) Some might want to run it more regularly. Also, this script does a rolling (or moving) seven-day backup. It assumes that your server has space for these backups. Some might want to combine this weekly backup scheme with a longer, like monthly, backup scheme. Also, it is good practice to mirror these backups to a secondary location. I am not practicing "good practice" yet, but it is on my list of things to do.
Disclaimer: I am not trained as a system administrator. I am only sharing what I have learned. It seems to work for me. Others will provide more help.