Copy a mongo db collection without locking whole mongod instance I am trying to run mongodb copy collection on same server.
Requirement is we delete database as per our archival policy but we need to keep one collection from this data as a backup in separate db on same server.
I run copyCollection but it takes lock on whole mongo instance and block all other operations.
Collection size is 10 GB so it takes considerable time while copying and system is unavailable for duration.
Please suggest a way to achieve this without locking whole instance.
I am trying to run mongodb copy collection on same server. Requirement
  is we delete database as per our archival policy but we need to keep
  one collection from this data as a backup in separate db on same
  server.


Yes, it's possible through mongoexport from your source db and mongoimport the collection to the target database on the same mongod server. 

Let's start from beginning. 

Suppose that i have two database StackExchange and StackOverflow in same mongod.

&gt; show dbs
StackExchange     0.000GB
StackOverflow     0.000GB


Suppose that in StackExchange there is collection orders having 4 documents.

&gt; show collections
orders
&gt;


Let's check there is documents records in Orders collection exist in StackExchange or not through mongo shell.

 &gt; db.orders.find().pretty()
{
        "_id" : ObjectId("5a44c1479adf6e5fc5cea526"),
        "cust_id" : "A123",
        "amount" : 250,
        "status" : "A"
}
{
        "_id" : ObjectId("5a44c1479adf6e5fc5cea525"),
        "cust_id" : "A123",
        "amount" : 500,
        "status" : "A"
}
{
        "_id" : ObjectId("5a44c1479adf6e5fc5cea528"),
        "cust_id" : "A123",
        "amount" : 300,
        "status" : "D"
}
{
        "_id" : ObjectId("5a44c1479adf6e5fc5cea527"),
        "cust_id" : "B212",
        "amount" : 200,
        "status" : "A"
}
&gt;


Here, as we can see that there is 4 document records in orders collection.

Suppose that  i want to copy the orders collection of  StackExchange database to the target database StackOverflow with targetorders documents name.

&gt;mongoexport -d StackExchange -c orders | mongoimport -d StackOverflow -c targetorders
2018-02-14T10:52:16.630+0300    connected to: localhost
2018-02-14T10:52:16.631+0300    exported 4 records
2018-02-14T10:52:16.693+0300    connected to: localhost
2018-02-14T10:52:17.047+0300    imported 4 documents


To verify the targetorders collection documents in StackOverflow database.

&gt; use StackOverflow
switched to db StackOverflow
&gt; show collections
targetorders
test
&gt; db.targetorders.find().pretty()
{
        "_id" : ObjectId("5a44c1479adf6e5fc5cea528"),
        "cust_id" : "A123",
        "amount" : 300,
        "status" : "D"
}
{
        "_id" : ObjectId("5a44c1479adf6e5fc5cea525"),
        "cust_id" : "A123",
        "amount" : 500,
        "status" : "A"
}
{
        "_id" : ObjectId("5a44c1479adf6e5fc5cea526"),
        "cust_id" : "A123",
        "amount" : 250,
        "status" : "A"
}
{
        "_id" : ObjectId("5a44c1479adf6e5fc5cea527"),
        "cust_id" : "B212",
        "amount" : 200,
        "status" : "A"
}
&gt;


So, here we can see all the 4 documents of orders collection from the StackExchange has successfully copied in StackOverflow.


  Very Import Note: Run mongoexport &amp; mongoimport from the system command line, not the mongo shell.


Hope this will help out to you.

For further your ref mongoexport and mongoimport