Is there a way to extract old OP_RETURN transactions from the commandline with bitcoin-cli or something? Something in the way of getAllOpRetFromBlock(345345) ...
There is not quite the method you are looking for, but you can use the
getblock call which takes the block hash (not height, you can get the hash of a specific height using
getblockhash method). That will give you the block, and you would then need to write a script to iterate through the transactions in the block and find ones which have an OP_RETURN output.