Eldritch Invocations (PHB, p. 107):
...Additionally, when you gain a level in this class, you can choose one of the invocations you know and replace it with another invocation that you could learn at that level.
Book of Ancient Secrets (BoAS) (PHB, p. 110):
Prerequisite: Pact of the Tome
You can now inscribe magical rituals in your Book of Shadows. Choose two 1st-level spells that have the ritual tag from any class’s spell list (the two needn’t be from the same list). The spells appear in the book and don’t count against the number of spells you know. With your Book of Shadows in hand, you can cast the chosen spells as rituals. You can’t cast the spells except as rituals, unless you’ve learned them by some other means. You can also cast a warlock spell you know as a ritual if it has the ritual tag.
On your adventures, you can add other ritual spells to your Book of Shadows. When you find such a spell, you can add it to the book if the spell’s level is equal to or less than half your warlock level (rounded up) and if you can spare the time to transcribe the spell. For each level of the spell, the transcription process takes 2 hours and costs 50 gp for the rare inks needed to inscribe it.
Assuming that the DM rules that the Rituals learned by BoAS don't vanish upon dismissing (old) BoAS:
Is it possible by RAW to gain two new ritual spells with every warlock level by switching the BoAS invocation with the BoAS invocation upon level-up?
Assuming that the DM rules that the spells learned from BoAS vanish:
Can a warlock copy a spell from his Book of Shadows to his Book of Shadows and preserve the Spells in this way to get more ritual spells by switching BoAS with BoAS on level-up?