I am in trouble an aggregation pipeline I ran corrupted one of my collections. Thought I was lucky since I have a backup of the DB dating only one hour earlier. Currently not able to restore. Here are the details:
The backup is created as follows:
mongodump --uri="mongodb://127.0.0.1:57777" --db memaback --archive=/home/bob/mongoback/${timestamp}_memaback.archive.gz --gzip
in a cron shell script that runs daily (and provides a timestamp for the datetime)
Resulting file is:
-rw-r--r-- 1 root root 2.3G May 7 07:05 20230507-070001_memaback.archive.gz
Now as I destroyed only my art collection in the memaback db I tried restoring the above file with the following command:
mongorestore --gzip --host 127.0.0.1 --port 57777 --db memaback --collection art 20230507-070001_memaback.archive.gz
which gives an error:
Failed: error scanning filesystem: file 20230507-070001_memaback.archive.gz does not have .bson or .bson.gz extension
so tried to rename the file to .bson.gz and ran the same command with the new filename but get:
Failed: memaback.art: error restoring from 20230507-070001_memaback.archive.bson.gz: reading bson input: invalid BSONSize: -2120621459 bytes is less than 5 bytes
The file is 2.3GB. The Linux ‘file’ command confirms its a gzipped file.
I also tried gunzipping it and the top of the resulting file seems promising (hopefully) and tried with this other syntax:
mongorestore --nsInclude=memaback.art --port 57777 20230507-070001_memaback.archive.bson
but get the same size error.
mongorestore --version:
mongorestore version: 100.7.0
git version: 17946f45f5fabfcdd99f8960b9109f976d370631
Go version: go1.19.3
os: linux
arch: amd64
compiler: gc
mongos version v4.4.19
Build Info: {
"version": "4.4.19",
"gitVersion": "9a996e0ad993148b9650dc402e6d3b1804ad3b8a",
"openSSLVersion": "OpenSSL 1.0.2g 1 Mar 2016",
"modules": [],
"allocator": "tcmalloc",
"environment": {
"distmod": "ubuntu1604",
"distarch": "x86_64",
"target_arch": "x86_64"
}
}
running on a VPS with Ubuntu 16.04 (yes stuck there unluckily)
Thanks for any help !!!