Steps :
-> Make the dump file for the current database of 2.4, and the dump file for previous database of 2.1
-> Make a new database (empty) and then reimport the database of 2.1 to this one.
-> And then Make the changes in env.php file of magento 2.4 and connect this database to your current magento 2.4 (connecting the 2.1 database to the magento 2.4).
-> After that Run the commands, Setup:upgrade, Compile, and deploy
After successfully running the commands, You have the data uptodate with the previous version.
NOTE : you have the dump file for the magento 2.4 db , so if any issue or exception occur just revert it, preventing the data loss.
I have tried this and it worked for me (2.3 to 2.4). Let me know if it works for you.