Open prabesh887 opened 3 years ago
how did you create this tar?
I simply run this code below, it generated the tar file, and when I tried to open that file on my PC its shows an error.
import { MongoTransferer, MongoDBDuplexConnector, LocalFileSystemDuplexConnector } from 'mongodb-snapshot';
async function dumpMongo2Localfile() {
const mongo_connector = new MongoDBDuplexConnector({
connection: {
uri: mongodb://<username>:<password>@<hostname>:<port>
,
dbname: <database-name>
,
},
});
const localfile_connector = new LocalFileSystemDuplexConnector({
connection: {
path: './backup.tar',
},
});
const transferer = new MongoTransferer({
source: mongo_connector,
targets: [localfile_connector],
});
for await (const { total, write } of transferer) {
console.log(`remaining bytes to write: ${total - write}`);
}
}
@prabesh887 with what program are you trying to open this tar? you need rar, the native zip in windows wont work.
or if you have unix shell, you can run tar -xvf backup.tar
@lihaibh I have tried it with the WinZip application, that didn't work. I ran tar -xvf backup.tar
via window's terminal, it generated JSON and BSON file types but those files are empty. Do I need to use any other kind of terminal?
@prabesh887 you need winrar to extract the file
@lihaibh Thanks. WinRAR worked, it open the files but inside all JSON file there is only {"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_"}],"uuid":""}
. Have I missed anything?
the json files are metadata about the collection, it contains the index details of the collection, you should have also bson files which are the actual encoded monodb data.
@prabesh887 the issue resolved for you?
I have successfully generated the backup file, but when I try to open that file, the file doesn't open. It throws an error as
Invalid archive header found
.