There is a build-in CLI for influxdb, in where you can execute the backup/restore command.
As far as Grafana goes, depending on which version you´ve got, there is a backup solution. But I have struggled with it, so i simply chose to export all the dashboards as json files, and then re-import them in the new setup. Rumors said you can just copy the grafana directory which contains the data. But I havn´t tried.
After last re-build of my system on a new hardware, I decided to leave Influxdb (as well as MQTT broker) on my old hardware, and just told the new setup where the database is located (local IP). The same goes for Grafana, which is now running on my Windows server. This way whatever happens to my openhab setup, which not have any influence on influxdb, MQTT broker or Grafana.
EDIT:
Here is a good link to show how to backup influxdb and grafana: