I'm gonna try to flash a Marshmallow rom on my Lollipop phone. How do I backup all apps? Do I need root and a custom recovery first? And if so, would they be deleted after I flash the new rom? And if I successfully flashed the new rom, would I be able to restore the backup files made on a lower version of Android work on this new rom?
Backup stuff with apps like Helium or Titanium Backup.
Custom recovery is required, while root is not; however you often need root to flash a custom recovery.
Recovery stays in its own partition and will not disappear, unless you deliberately chose not to remove a script that replaces it with the stock one (this mostly happens on stock ROMs).
It's usually safe to restore data for user apps; however do be careful when taking care of system apps - especially don't just backup and restore data for Settings.