Home | 简体中文 | 繁体中文 | 杂文 | 打赏(Donations) | Github | OSChina 博客 | 云社区 | 云栖社区 | Facebook | Linkedin | 知乎专栏 | 视频教程 | About

44.2. mongodump - Backup

		
# mongodump -uneo -p -d test -o /tmp/
connected to: 127.0.0.1
Enter password:
Tue Sep 8 10:12:33.011 DATABASE: test to /tmp/test
Tue Sep 8 10:12:33.012 test.system.indexes to /tmp/test/system.indexes.bson
Tue Sep 8 10:12:33.043 12 objects
Tue Sep 8 10:12:33.043 test.bios to /tmp/test/bios.bson
Tue Sep 8 10:12:33.043 1 objects
Tue Sep 8 10:12:33.043 Metadata for test.bios to /tmp/test/bios.metadata.json
Tue Sep 8 10:12:33.043 test.system.users to /tmp/test/system.users.bson
Tue Sep 8 10:12:33.044 2 objects
Tue Sep 8 10:12:33.044 Metadata for test.system.users to /tmp/test/system.users.metadata.json
Tue Sep 8 10:12:33.044 test.fs.chunks to /tmp/test/fs.chunks.bson
Tue Sep 8 10:12:33.045 2 objects
Tue Sep 8 10:12:33.045 Metadata for test.fs.chunks to /tmp/test/fs.chunks.metadata.json
Tue Sep 8 10:12:33.045 test.fs.files to /tmp/test/fs.files.bson
Tue Sep 8 10:12:33.046 2 objects
Tue Sep 8 10:12:33.046 Metadata for test.fs.files to /tmp/test/fs.files.metadata.json
Tue Sep 8 10:12:33.046 test.images.chunks to /tmp/test/images.chunks.bson
Tue Sep 8 10:12:33.167 12 objects
Tue Sep 8 10:12:33.167 Metadata for test.images.chunks to /tmp/test/images.chunks.metadata.json
Tue Sep 8 10:12:33.167 test.images.files to /tmp/test/images.files.bson
Tue Sep 8 10:12:33.168 3 objects
Tue Sep 8 10:12:33.168 Metadata for test.images.files to /tmp/test/images.files.metadata.json
Tue Sep 8 10:12:33.168 test.img.chunks to /tmp/test/img.chunks.bson
Tue Sep 8 10:12:33.175 4 objects
Tue Sep 8 10:12:33.175 Metadata for test.img.chunks to /tmp/test/img.chunks.metadata.json
Tue Sep 8 10:12:33.175 test.img.files to /tmp/test/img.files.bson
Tue Sep 8 10:12:33.176 1 objects
Tue Sep 8 10:12:33.176 Metadata for test.img.files to /tmp/test/img.files.metadata.json
		
		

44.2.1. 远程备份

短参数

			
mongodump -h mongodb.example.net -p 27017 -u neo -p password -d netkiller -c yourcollection
			
			

长参数

			
mongodump --host mongodb.example.net --port 27017 --username backup --password passwd --db mdb --collection some
			
			

44.2.2. 本地备份

通过指定dbpath在本地导出bson文件

			
mongodump --dbpath /var/lib/mongodb --out /opt/backup --db test --username backup --password passwd