How do you export all topics in Kafka?

To export all topics in Kafka, you can use the command-line tool provided by the kafka-topics.sh script to do this. The following are the steps to export all topics.

  1. Open the terminal and navigate to the installation directory of Kafka.
  2. List all the topics using the following command:
./bin/kafka-topics.sh --list --bootstrap-server localhost:9092

Make sure to replace localhost:9092 with the correct address and port of your Kafka cluster.

  1. Save all the listed topics to a file using the following command.
./bin/kafka-topics.sh --list --bootstrap-server localhost:9092 > topics.txt

This will output the list of topics to a file named topics.txt. You can choose any other file name and path.

You have now successfully exported all the topics in Kafka and saved them to a file.

广告
Closing in 10 seconds
bannerAds