shell copy mongodb database

Copy mongodb database

mongodump -h 服务器IP --port 端口 -u 用户名 -p 密码 -d 数据库 -o 导出路径
  • -h: The address of the server where MongoDB is located, for example: 127.0.0.1, of course you can also specify the port number: 127.0.0.1:27017
  • -u: connection username
  • -p: connection password
  • -d: the database instance that needs to be backed up, for example: test
  • -o: backup data storage location, for example: c:\data\dump

path

It can be used with "$(date + "%Y-%m-%d")" to perform scheduled tasks to back up the database by date every day

/www/路径/" $(date +"%Y-%m-%d")"

question

There are no mongodump and mongorestore commands in the bin directory

Missing tools go to https://www.mongodb.com/try/download/database-tools to download

Guess you like

Origin blog.csdn.net/weixin_41891519/article/details/124386211