Documentation ¶
Overview ¶
Package mongodump creates BSON data from the contents of a MongoDB instance.
Index ¶
- Variables
- type IndexDocumentFromDB
- type InputOptions
- type Metadata
- type MongoDump
- func (dump *MongoDump) CreateAllIntents() error
- func (dump *MongoDump) CreateCollectionIntent(dbName, colName string) error
- func (dump *MongoDump) CreateIntentsForDatabase(dbName string) error
- func (dump *MongoDump) CreateOplogIntents() error
- func (dump *MongoDump) CreateUsersRolesVersionIntentsForDB(db string) error
- func (dump *MongoDump) Dump() (err error)
- func (dump *MongoDump) DumpIntent(intent *intents.Intent, buffer resettableOutputBuffer) error
- func (dump *MongoDump) DumpIntents() error
- func (dump *MongoDump) DumpMetadata() error
- func (dump *MongoDump) DumpOplogBetweenTimestamps(start, end primitive.Timestamp) error
- func (dump *MongoDump) DumpUsersAndRoles() error
- func (dump *MongoDump) DumpUsersAndRolesForDB(name string) error
- func (dump *MongoDump) GetValidDbs() ([]string, error)
- func (dump *MongoDump) HandleInterrupt()
- func (dump *MongoDump) Init() error
- func (dump *MongoDump) NewIntentFromOptions(dbName string, ci *db.CollectionInfo) (*intents.Intent, error)
- func (dump *MongoDump) ValidateOptions() error
- type NilPos
- type Options
- type OutputOptions
Constants ¶
This section is empty.
Variables ¶
var Usage = `` /* 325-byte string literal not displayed */
Functions ¶
This section is empty.
Types ¶
type IndexDocumentFromDB ¶
IndexDocumentFromDB is used internally to preserve key ordering.
type InputOptions ¶
type InputOptions struct { Query string `long:"query" short:"q" description:"query filter, as a v2 Extended JSON string, e.g., '{\"x\":{\"$gt\":1}}'"` QueryFile string `long:"queryFile" description:"path to a file containing a query filter (v2 Extended JSON)"` ReadPreference string `` /* 220-byte string literal not displayed */ TableScan bool `` /* 146-byte string literal not displayed */ }
InputOptions defines the set of options to use in retrieving data from the server.
func (*InputOptions) GetQuery ¶
func (inputOptions *InputOptions) GetQuery() ([]byte, error)
func (*InputOptions) HasQuery ¶
func (inputOptions *InputOptions) HasQuery() bool
func (*InputOptions) Name ¶
func (*InputOptions) Name() string
Name returns a human-readable group name for input options.
type Metadata ¶
type Metadata struct { Options bson.D `bson:"options,omitempty"` Indexes []bson.D `bson:"indexes"` UUID string `bson:"uuid,omitempty"` CollectionName string `bson:"collectionName"` Type string `bson:"type,omitempty"` }
Metadata holds information about a collection's options and indexes.
type MongoDump ¶
type MongoDump struct { // basic mongo tool options ToolOptions *options.ToolOptions InputOptions *InputOptions OutputOptions *OutputOptions // Skip dumping users and roles, regardless of namespace, when true. SkipUsersAndRoles bool ProgressManager progress.Manager // useful internals that we don't directly expose as options SessionProvider *db.SessionProvider // Writer to take care of BSON output when not writing to the local filesystem. // This is initialized to os.Stdout if unset. OutputWriter io.Writer // contains filtered or unexported fields }
MongoDump is a container for the user-specified options and internal state used for running mongodump.
func (*MongoDump) CreateAllIntents ¶
CreateAllIntents iterates through all dbs and collections and builds dump intents for each collection. Returns the db names that the intents are created from.
func (*MongoDump) CreateCollectionIntent ¶
CreateCollectionIntent builds an intent for a given collection and puts it into the intent manager. It should only be called when a specific collection is specified by --db and --collection.
func (*MongoDump) CreateIntentsForDatabase ¶
CreateIntentsForDatabase iterates through collections in a db and builds dump intents for each collection.
func (*MongoDump) CreateOplogIntents ¶
CreateOplogIntents creates an intents.Intent for the oplog and adds it to the manager
func (*MongoDump) CreateUsersRolesVersionIntentsForDB ¶
CreateUsersRolesVersionIntentsForDB create intents to be written in to the specific database folder, for the users, roles and version admin database collections And then it adds the intents in to the manager
func (*MongoDump) DumpIntent ¶
DumpIntent dumps the specified database's collection.
func (*MongoDump) DumpIntents ¶
DumpIntents iterates through the previously-created intents and dumps all of the found collections.
func (*MongoDump) DumpMetadata ¶
DumpMetadata dumps the metadata for each intent in the manager that has metadata
func (*MongoDump) DumpOplogBetweenTimestamps ¶
DumpOplogBetweenTimestamps takes two timestamps and writer and dumps all oplog entries between the given timestamp to the writer. Returns any errors that occur.
func (*MongoDump) DumpUsersAndRoles ¶
DumpUsersAndRoles dumps all of the users and roles and versions TODO: This and DumpUsersAndRolesForDB should be merged, correctly
func (*MongoDump) DumpUsersAndRolesForDB ¶
DumpUsersAndRolesForDB queries and dumps the users and roles tied to the given database. Only works with an authentication schema version >= 3.
func (*MongoDump) GetValidDbs ¶
func (*MongoDump) HandleInterrupt ¶
func (dump *MongoDump) HandleInterrupt()
func (*MongoDump) NewIntentFromOptions ¶
func (*MongoDump) ValidateOptions ¶
ValidateOptions checks for any incompatible sets of options.
type Options ¶
type Options struct { *options.ToolOptions *InputOptions *OutputOptions }
type OutputOptions ¶
type OutputOptions struct { Out string `long:"out" value-name:"<directory-path>" short:"o" description:"output directory, or '-' for stdout (default: 'dump')"` Gzip bool `long:"gzip" description:"compress archive or collection output with Gzip"` Oplog bool `long:"oplog" description:"use oplog for taking a point-in-time snapshot"` Archive string `` /* 197-byte string literal not displayed */ DumpDBUsersAndRoles bool `long:"dumpDbUsersAndRoles" description:"dump user and role definitions for the specified database"` ExcludedCollections []string `` /* 173-byte string literal not displayed */ ExcludedCollectionPrefixes []string `` /* 212-byte string literal not displayed */ NumParallelCollections int `long:"numParallelCollections" short:"j" description:"number of collections to dump in parallel" default:"4" default-mask:"-"` ViewsAsCollections bool `` /* 128-byte string literal not displayed */ }
OutputOptions defines the set of options for writing dump data.
func (*OutputOptions) Name ¶
func (*OutputOptions) Name() string
Name returns a human-readable group name for output options.