I have a latex document which has several citations. These citations are from my global .bib file that I manage with JabRef. The documentclass of my document is IEEEtran (I doubt my use of IEEEtran affects the answer, but this is my usecase, so I figured I would ask in context).

I am getting ready to share my document (and the .tex file) and would like to share a minimal working .bib file with it. My question is: is there an automated way of extracting the entries from a .bib file using the .tex or .aux files of a document so that the output .bib only contains the bibtex entries cited by the document?

Obviously, I could manually go through my document, find the keys, copy the relevant entries from my global .bib file to one called standlone.bib or some such. But I'm curious if there are any extant automated ways. Or if there are not any automated ways, are there any simple commands to get there?

I have been searching and was unable to find any answers to this question, so please forgive me if this is a duplicate as I did not know what terms to search for beyond "latex standalone bib from tex", etc.

For completeness, suppose I have a document such as the below MWE snippet in a file called document.tex.

% document.tex

% ... Various preamble commands


Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
Sed mattis pellentesque mauris. Sed non nisi ut velit 
ullamcorper congue non eu erat. Aliquam pharetra nibh
magna, eu consectetur risus aliquet vel. Aenean eget
turpis dui. \cite{key1}

Sed in tristique nibh, vel ultricies lorem. Pellentesque
sem lacus, maximus ac laoreet eu, mattis at sem. Maecenas
dignissim sagittis nisl, non interdum nunc auctor nec.
Proin ac ipsum quis lorem placerat accumsan sed quis sem. \cite{key2}

% ...



Example of the command I hope exists:

$ exportbibfromdoc --stand-alone-bib document.tex -o standalone.bib

so that the output would be

% standalone.bib



Thanks in advance for any help!