How do you backup Zookeeper?

Krishna Sankar picture Krishna Sankar · Jun 18, 2011 · Viewed 19.6k times · Source

I have read that copying the data directory will work. But, that is a combination of logs and snapshots. How do folks backup a zookeeper infrastructure ? Export ? Dump ? Custom script ? What are the best practices ?

Answer

manku picture manku · Jun 24, 2011

Zookeeper writes a snapshot once it determines that it has enough transactions and every new snapshot completely supersedes older ones. So the latest snapshot + the transaction log from the time of the snapshot is enough to recover to current state. To make the calculations easier, you can simply backup the last 3 snapshots(in case of corruption of the latest snap) and the transaction logs from the timestamp corresponding to the earliest snapshot. The links below have some more details.

  1. http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_dataFileManagement
  2. http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance