I wish to possess a clone of the postgresql database. Basically copy the whole data directory in one machine and replace another machine's data directory by using it, maybe there is any problems? each of them have a similar OS, btw (CentOS)

Certainly should you steer clear of the server after which copy it, that's fine. If you do not, the cloned server will need to do recovery, which is not so great. Or simply use pg_dumpall to make a script to recreate the information around the new machine.

You are able to invoke pg_start_backup() after which copy the datadir. All changes will be written to some "log" and committed afterwards advertising media are pg_stop_backup().


Se section 23.3.2. Creating a Base Backup

Then i think you are able to restore the files on another machine running identical versions of postgresql underneath the same architecture.

section 23.3.3. Recuperating by having an On-line Backup will show you how you can restore the backup you earn.