I was reading the snapshot and restore section from the documentation and it said that it isn't recommended to just copy and paste the folder because there might be some data loss.
It is not possible to back up an Elasticsearch cluster simply by taking a copy of the data directories of all of its nodes. Elasticsearch may be making changes to the contents of its data directories while it is running, and this means that copying its data directories cannot be expected to capture a consistent picture of their contents. Attempts to restore a cluster from such a backup may fail, reporting corruption and/or missing files, or may appear to have succeeded having silently lost some of its data. The only reliable way to back up a cluster is by using the snapshot and restore functionality.
However, the standard upgrade section says the following:
Copy the files from the
data
directory from your old installation to your new installation