Differences between revisions 5 and 6
Revision 5 as of 2020-06-07 08:09:01
Size: 848
Editor: PieterSmit
Comment:
Revision 6 as of 2020-07-15 08:02:40
Size: 1083
Editor: PieterSmit
Comment:
Deletions are marked like this. Additions are marked like this.
Line 26: Line 26:

Line 27: Line 29:

 * Mongo restore from archive to new db name {{{
mongorestore --host 127.0.0.1:27017 --gzip --archive=latest.dump.gz --nsFrom "olddb.*" --nsTo "newdb.*" --username user --password "abcdefg"
--authenticationDatabase newdb
}}}

MongoDb / MongoBackup MongoRestore

  • Links: Linux/Backups

  • Mongo backup

    export u="UserMongo"
    export p="PwdSecret"
    export d="dbprd"
    export h="mongodb+srv://$u:$p@prd.mongodb.net/$d?readPreference=secondary"
    export c="coll_data"
    echo "#$u , $p , $h , $d , $c"
    echo " --out /tmp/dump-$dr-$c.bson"
    
    time docker run -it -v /tmp:/mnt -e h="$h" -e c=$c -e d=$d mongo mongodump --uri="$h" --collection="$c" --gzip --archive=/mnt/dump-$d-$c.bson
  • Mongo restore

    export u="adminUSR"
    export p="admPWD"
    export d="dbprd"
    export h="mongodb+srv://$u:$p@cluster0.mongodb.net/admin"
    export c="coll_data"
    ls -l /tmp/dump-$d-$c.bson
    
    time docker run -i -v /tmp:/mnt -e h="$h" -e c=$c -e d=$d mongo \
              mongorestore --uri="$h" -v -v --gzip --drop --db=$d --collection="$c" --archive=/mnt/dump-$d-$c.bson
  • Mongo restore from archive to new db name

    mongorestore --host 127.0.0.1:27017 --gzip --archive=latest.dump.gz --nsFrom "olddb.*" --nsTo "newdb.*" --username user --password "abcdefg"
    --authenticationDatabase newdb

MongoDb/MongoBackupRestore (last edited 2020-07-15 08:02:40 by PieterSmit)