It is sometimes useful to extract only the relevant bibtex entries from your bibliography file – for example, if you are using a big bib file as default, such as geombib (which is now outdated). There are two solutions I am aware of:

  1. Using bibtool, you can do (from the command line):

    bibtool --pass.comments=on --print.line.length=140 -x paper.aux -o test.bib

    This works very well, and extracts all the relevant bibtex entries, macros, and even (relevant) preamble macros/commands.

  2. Emacs has a minor mode called bib-cite-minor-mode. Once activated you can issue the command bib-make-bibliography, which creates a buffer with all the relevant entries. Works reasonably well, but does handle preamble macros correctly like bibtool. Still pretty useful.
    As pointed out by Marcus (see comment), there is also reftex-create-bibtex-file which also works (with similar limitations).
  1. Another option is to use “reftex-create-bibtex-file” in reftex-mode.