Getmail is probably your best bet for an automated email backup - that will fetch your email over IMAP (getmail-gmail-xoauth-tokens can use oauth to connect to IMAP) and store it as a maildir or mbox. You can then use that with whatever client or search system you like.
You could then use this maildir as the backend for a dovecot IMAP server and use any webmail client of your choosing to connect to this and search it etc.
I'd avoid POP3 - very old protocol and it removes your mail from the server (is this your goal?). You're definitely better using IMAP. Even if you want to delete mail from the server, you're probably safer to fetch it by IMAP, then delete it.