@@ -40,27 +40,27 @@ Considerations
40
40
- You can run :dbcommand:`copydb` or :dbcommand:`clone` commands on a
41
41
:term:`secondary` member.
42
42
43
- - There must be enough free disk storage on the destination server for the
44
- database from the source server. You can check for the size of the
45
- database on the source server by issuing command:
46
-
47
- .. code-block::
48
-
49
- db.runCommand()
43
+ - There must be enough free disk storage on the destination server for
44
+ the database from the source server. Use the ``db.stats()`` function
45
+ to check the size of the database on the source :program:`mongod`
46
+ instance. For more information on ``db.stats()`` see the
47
+ :doc:`database statistics </reference/database-statistics>` section.
50
48
51
49
Process
52
50
-------
53
51
54
52
Copy a Database to Another Server
55
53
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
56
54
57
- Use the :dbcommand:`copydb` command to transfer a database from
58
- one MongoDB instance to another, such as from a development instance
59
- to a production instance.
55
+ Use the :dbcommand:`copydb` command to transfer a database from one
56
+ MongoDB instance to another, such as from a development instance to a
57
+ production instance. The :func:`db.copyDatabase()` helper in the
58
+ :program:`mongo` shell provides a wrapper around the
59
+ :dbcommand:`copydb`.
60
60
61
61
This is useful when you want to move a database from the development
62
- environment to the production environment, or create a remote-branch of the database
63
- to archive the current database on a different server.
62
+ environment to the production environment, or create a remote-branch
63
+ of the database to archive the current database on a different server.
64
64
65
65
To copy the database named ``test`` on server ``db0.example.net`` to
66
66
another server ``db1.example.net`` renaming it ``records`` in the process.
@@ -83,7 +83,9 @@ Rename a Database
83
83
Use the :dbcommand:`copydb` command to copy a database within the same
84
84
server also renaming the database. This is useful when the contents of
85
85
the database has changed from the initial naming of the database and a
86
- new name would be more appropriate.
86
+ new name would be more appropriate. The :func:`db.copyDatabase()`
87
+ helper in the :program:`mongo` shell provides a wrapper around the
88
+ :dbcommand:`copydb`.
87
89
88
90
To rename a database from ``test`` to ``records`` within the
89
91
same server, ``db1.example.net``.
@@ -104,7 +106,9 @@ If the source server requires ``username`` and ``password``, you can
104
106
include these parameters in the :dbcommand:`copydb` command. This is
105
107
useful where you need to create offsite backups, a local development
106
108
system which has data from the production system, or create a system
107
- to produce reports.
109
+ to produce reports. The :func:`db.copyDatabase()` helper in the
110
+ :program:`mongo` shell provides a wrapper around the
111
+ :dbcommand:`copydb`.
108
112
109
113
To copy ``test`` to ``records`` from the source server
110
114
``db0.example.net``, which requires ``username`` and ``password``
@@ -122,11 +126,12 @@ authentication, to ``db1.example.net`` use the following procedure.
122
126
Clone a Database
123
127
~~~~~~~~~~~~~~~~
124
128
125
- The :dbcommand:`clone` command copies a database between :program:`mongod`
126
- instances; however, :dbcommand:`clone` preserves the database
127
- name on the destination server. For many operations,
129
+ The :dbcommand:`clone` command copies a database between
130
+ :program:`mongod` instances; however, :dbcommand:`clone` preserves the
131
+ database name on the destination server. For many operations,
128
132
:dbcommand:`clone` has identical functionality and a simpler syntax
129
- than :dbcommand:`copydb`.
133
+ than :dbcommand:`copydb`. The :func:`db.cloneDatabase()` helper in the
134
+ :program:`mongo` shell provides a wrapper around :dbcommand:`clone`.
130
135
131
136
To clone a database from ``db0.example.net`` to ``db1.example.net``, on
132
137
``db1.example.net`` follow these procedures.
0 commit comments