Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 126 additions & 0 deletions draft/tutorial/copy-database.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
=================================================
Copy or Clone Database without Intermediate Files
=================================================

.. default-domain:: mongodb

Sypnosis
--------

One may need to copy a :term:`database` from one server to another,
rename a :term:`database`, or move a :term:`database` within the same
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you only need to use :term: for the first occurrence of a term in a section.

server, seed a development server from a production server, or create
a test environment with production data. The :program:`copyDatabase`
and :program:`cloneDatabase` function in MongoDB can help one in these
situations.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No where else in the documentation do we use the second person formal "i.e. One." because it sounds stilted, and isn't necessary. It's particularly awkard in this case because you use the informal later in the document.

In some situations you may want to copy a database from one MongoDB instance to another. For example, you may use these commands to support migrations and data warehousing, seeding test environments, or to help perform backups.


This document oulines the procedure to copy MongoDB :term:`databases`
using the :program:`copyDatabase` and :program:`cloneDatabase`
command.

While :program:`mongodump` and :program:`mongorestore` tools are
available, the copy database commands are faster as there are no
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this sentence isn't grammatically correct.

something more along the lines of: mongodump and mongorestore provide similar functionality; however...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they're not just available, but they preform related functionality.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

faster because the commands do not require intermediate files.

intermediate files to be created.

.. warning::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is really a note.


Copy procedures with :program:`copyDatabase` and
:program:`cloneDatabase` do not lock the database, so writes may
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use :dbcommand: rather than :program: for database commands. :func: annotates shell helpers.

so:

  • clone is a database command
  • copydb is a database command
  • db.copyDatabase() is a shell helper.
  • db.cloneDatabase() is a shell helper.

still occur during the copy process at the source. This will
produce a destination database that is inconsistent with the source
database.

If your needs are for consistent database copies, consider using
:program:`mongodump` and :program:`mongorestore` instead. More
details on these programs can be found in :ref:`database dump
<database-dump>` and :ref:`database restore <database-restore`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to be careful about using the word "inconsistent," which I think most people read as "corrupt," in the case of databases.

:dbcommand:copydb and :dbcommand:cloneDatabase do not produce point-in-time snapshots of the source (origin?) database. Write traffic to the origin (or desitination? check?) during the copy process may in databases with different contents.

Also unless you use the --oplog and --oplog replay operations, mongodump and mongorestore have the same behavior.


Considerations
--------------

- These commands must be run on the destination server.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which commands?

consider the possibility that people might start reading this document at the "considerations" header.


- These commands do not work with the total data set of a :term:`shard
cluster`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"total data set" is not a specific term that we've used in any context. It's not entirely accurate. The actual compatibility issue, would be good to cover:

is this operation totally blocked in shard clusters. does it work for databases that don't have sharded collections? that don't have sharding enabled?


- There must be enough free disk storage on the destination server for the
database from the source server.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The destination server must have sufficient free space for the database you are copying.

(I would put this lower on the list becasue while it's true, and must be said, but it's sort of obvious and I fear people might not read the next point, which is not obvious.)


- The :program:`copyDatabase` commands may be run on a :term:`secondary`
member.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • see above regarding semantics for copyDatabase
  • s/commands/commnad/
  • member of what.



Process
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Procedures.

-------

Copy a Database from Another Server
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To copy database named ``test`` on server ``db0.example.net`` to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the database

another server ``db1.example.net`` naming it to ``records``.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/naming it to/renaming it/


- Verify name of database, ``test``, you want to copy on the source
server, ``db0.example.net``.

- Log onto the destination server, ``db1.example.net``.

- Run the following command from :program:`mongo shell` on the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/command/operation/

s/:program:mongo shell/:program:mongo shell/

destination server, ``db1.example.net``.

.. code-block:: javascript

db.copyDatabase( test, records, db0.example.net )

Copy a Database within a Server
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this title should be "rename a database" to reflect actual useage.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To rename a database from ``test`` to ``records`` within the
same server, ``db1.example.net``.

- Log onto the destination server, ``db1.example.net``.

- Run the following command from :program:`mongo shell` on the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  :program:`mongo` shell

not

 :program:`mongo shell`

destination server, ``db1.example.net``.

.. code-block:: javascript

db.copyDatabase( test, records )

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for all of these examples I think it's important to provide links to the database command names (in case people want to use the drivers.)

also to note might be good to what the output is in the shell.

Copy a Database with Authentication
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If the source server requires ``username`` and ``password``
authentication, you can include these parameters in the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no other form of authentication

:program:`copyDatabase` command.

To copy ``test`` to ``records`` from the source server
``db0.example.net``, which requires ``username`` and ``password``
authentication, to ``db1.example.net`` use the following procedure.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs a colon.


- Log onto the destination server, ``db1.example.net``.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you'll see the change in my diff, but "Log onto" isn't what you mean.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I remember this now. I think I wrote this before we talked about the difference between Logon and Login...


- Run the following command from :program:`mongo shell` on the
destination server, ``db1.example.net``.

.. code-block:: javascript

db.copyDatabase( test, records, db0.example.net, username, password)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation isn't correct given the context.

probably need to correct throughout.


Copy a Database Using CloneDatabase Command
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:program:`cloneDatabase` is similar to :program:`copyDatabase` but is
limited to only copying a database from another server while
preserving the database name.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:dbcommand:clone copies a database between :program:mongod instances; however, :dbcommand:clone preserves the database name. For many operations :dbcommand:clone has a more straightforward syntax that :dbcommand:copydb.

(or something along these lines.)


To copy a database from ``db0.example.net`` to ``db1.example.net``, on
``db1.example.net`` follow these procedures.

- Log onto the destination server, ``db1.example.net``.

- Run the following command from :program:`mongo shell` on the
destination server, ``db1.example.net``.

.. code-block:: javascript

db.cloneDatabase( db0.example.net )