备份名称为 mydb 的数据库文件名增加备份时间戳并gzip压缩。
1 | mongodump --archive="mydb`date '+%Y%m%d%H%M'`.gz" --gzip --db=mydb |
恢复 mydb
mongorestore命令的--db
参数是选择备份文件中的DB,而非恢复的DB名称,MongoDB 3.2中无法指定恢复的DB名称
1 | mongorestore --gzip --archive='mydb202010191212.gz' |
备份名称为 mydb 的数据库文件名增加备份时间戳并gzip压缩。
1 | mongodump --archive="mydb`date '+%Y%m%d%H%M'`.gz" --gzip --db=mydb |
恢复 mydb
mongorestore命令的--db
参数是选择备份文件中的DB,而非恢复的DB名称,MongoDB 3.2中无法指定恢复的DB名称
1 | mongorestore --gzip --archive='mydb202010191212.gz' |