好,我坚持使用脚本来备份mongodb的集合,2.6版本不支持--gzip后缀,有什么方法可以使用其他方式来存档集合,以及在需要安全地进行mongo还原的情况下?非常感谢你读我的帖子。
#specify collections
collection_list="students loans.lib help.archive"
#if its running on local machine:
host="127.0.0.1"
port="27208"
#where to dump:
out_prefix="/apps/mongodb/uni/backup/mongodump"
for collection in $collection_list; do
echo $collection
out_dir="${out_prefix}/${db}_${collection}.$(date +%Y.%m.%d)/"
mkdir -p ${out_dir}
/apps/mongodb/server/2.6.2/bin/mongodump -u -p --host $host --port $port -d $db --collection $collection --out ${out_dir}
done--gzip是不被承认的:( P.S.我无法升级我们的旧大学mongodb,我们没有预算。
发布于 2021-12-06 18:05:39
如果您需要在没有MongoDB3.2中引入的"--gzip“选项的情况下动态压缩,那么在linux中可以这样做:
mongodump -d yourDB -c yourCOL -o - | gzip > yourDByourCOLdump.gz要还原它,可以这样做:
gunzip yourDByourCOLdump.gz
mv yourDByourCOLdump yourDByourCOLdump.bson
mongorestore -d yourDB -c yourCOL yourDByourCOLdump.bsonhttps://stackoverflow.com/questions/70248064
复制相似问题