The first and simplest approach is delete all generated library files – proxies, optimized, renders, etc. That shrinks the library itself to a small size.
For media archiving, you have a choice of the entire library or just the project (ie timeline). If it’s a single (or a few) projects built from a large library, maybe only a small % of the media was actually used. If the non-used media isn’t needed for archival purposes, you can create an “archive library”, configure it for “in library storage”, then drag/drop the projects to that and consolidate. Thereafter that archive library will contain only the media actually used and the edits for the timelines. However if various 3rd-party plugins or effects were used, you’d need a plan to also save those.
FCPX doesn’t trim used clip ranges when copying to another library. If you need that, there is Worx 4 X, but it has some limitations: https://itunes.apple.com/us/app/worx4-x/id1195903030?ls=1&mt=12
If you need to save all the media whether it was used or not, just backup the entire media tree and library. If you aren’t sure where all the media is, Final Cut Library Manager can produce a spreadsheet of each file and pathname: https://www.arcticwhiteness.com/finalcutlibrarymanager/
There is also Reference X, a stand-alone utility which displays all media files and the paths used by a library, and can optionally copy them to a user-specified location: https://itunes.apple.com/us/app/reference-x/id1291743117?mt=12
There is the new concern over archiving FCPX media which might use encoding formats not be supported in future versions. IOW you theoretically could save media and library (maybe even a managed library with all media internal), then pull it off the shelf in three years and find that FCPX 11 won’t read it. This is a separate issue that requires its own discussion thread. If you are concerned about this you could transcode to optimized media and save that, although it would be a lot bigger.