What is the right way to locally copy pinned data in ipfs and what is the use of datastore folder?

377 views Asked by At

I figured out pinned data is cached in blocks folder. Can I just get away with copying the files I need in blocks folder to backup? Is datastore folder generated automatically by ipfs daemon?

I tried copying only the blocks folder to another ipfs deamon and it recognized the .data files as pinned files and created a different datastore folder.

1

There are 1 answers

0
Daniel On

There are three stores used by Kubo (formerly go-ipfs):

  • Key store storing private/public keys for PeerID and IPNS
  • Data store
  • Block store

These have folders in the .ipfs directory used by Kubo (with default configuration which uses leveldb for data store and flatfs for blockstore).

  • datastore folder: used by leveldb to store things like pins and MFS roots
  • blocks folder where blocks are stored. This includes non-pinned blocks that are cached by your node.

You could copy the blocks folder to another IPFS daemon with the same configuration. However, I'd be aware that it may not be the best way to do this, especially if the node is running and modifying the blocks folder.

A much more explicit way would be to use the ipfs dag export <CID> command to export .car files.

.car files are convenient because they can be imported into another IPFS node and contain inside all the blocks.