How does the IPFS decide how many copies of a certain file to maintain?
It doesn’t, if people holds copy, they hold copy, but IPFS never takes any initiative.
A file will be stored in multiple locations, if multiple people (or one guy managing multiple nodes) pins the file, or if someone who downloaded your file, has the reproviding service enabled (it’s the default).
How does i decide where to maintain them?
If you are using IPFS alone, just pin them on multiple nodes you own.
You can use ipfs-cluster to make that task way more simpler and manage multiple nodes as one.
Under what conditions would that file be completely removed from the IPFS?
If every nodes hosting a file either goes offline or run the garbage collection and remove that file from their local cache.
Note an offline node might spin back up, or someone else can add the same file back, so you can never truely be certain that a file will be erased.
You need to think that IPFS may just never forget and there is nothing you can do about it.
So basically as long as you have it pinned somewhere it never goes away - that is a way to keep something around for sure. And I presume even if you weren’t the one who introduced a file into the system, as long as you replicate it and pin it, you can still get it to stay, correct?
It would be cool if there was some sort of charitable replication strategy. If I allocate 20G to IPFS and only put 1G in there it would be cool if IPFS would pin anything that it saw that under replicated and unpin it as I put more explicit pins in there. If it’s under replicated it isn’t very popular so it isn’t going to cost me much bandwidth and the disk space is just sitting there unused.