MFS File + Pin Replication in Cluster

Hello,
I have a two node cluster with replication_factor: -1 configured. I have a directory structure on my main ipfs node with many files in it and I would like to fully replicate this structure to other cluster node.
I’ve looked other discussions but they mostly include pin replication, is there a way to automatically fully replicate the directory structure with file names (because I’m using unique file names to get files) ?

Thank you.

No. You need to export things from the MFS and pin that.
You can do:

ipfs-cluster-ctl pin add $(ipfs files stat / --hash)

That will create a “snapshot” of your current MFS and pin that.
If you change your MFS you will need to rerun that (and potentially removing the previous version).

I am using the cluster API for pinning the files right after writing into MFS on the main node.
Normally, first I write file to MFS on the main node and then take its CID and pin on the cluster.
curl -X POST -F file=@myfile "http://127.0.0.1:5001/api/v0/files/write?arg=<path>
http://localhost:9094/pins/<cid>

So in this case I should first get the stat output
curl -X POST "http://127.0.0.1:5001/api/v0/files/stat?arg=/<path_to_a_file>"
then it’s getting a bit fuzzy :slight_smile:

I’ve already pinning the files with ipfs-cluster-ctl pin add <CID> but this only makes replication of the pin. But I’m curious about how to replicate the file itself ?

You would have to set the MFS root in all your peers (currently not something go-ipfs lets you do).

If you wrap all your content in a folder inside the MFS root you could then ipfs files cp /ipfs/<pin_cid> /mystuff.

Cluster does not offer a way of doing this/managing MFS everywhere though, but I’m thinking about it.

Cool, thank you !
The good thing about MFS you can easily write files and retrieve by their names. I like its straightforwardness :slight_smile:

It would be really cool if you could register callbacks to ipns pubsub updates.