How to backup data on WhatsApp:
First of all you have to open WhatsApp on your phone.
After that you have to go to Settings.
After going to settings, you have to go to the chat section.
Now you have to tap on Chat Backup.
Now you have to click on Chat Backing Up, here you can select your Google account where you want the backup.
After doing this, your chat has now started uploading to the cloud. Once the backup is complete, you can login to your WhatsApp account on the device you are switching to. Here you will get the option of Search for Backup and then tap on Restore Backup. Once all this is done, your entire chat history including media files has been restored to your new device.