ditto icon indicating copy to clipboard operation
ditto copied to clipboard

backup.tar file invalid

Open prabesh887 opened this issue 4 years ago • 8 comments

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.

prabesh887 avatar May 07 '21 13:05 prabesh887

how did you create this tar?

lihaibh avatar May 07 '21 16:05 lihaibh

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 avatar May 08 '21 02:05 prabesh887

@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 avatar May 27 '21 08:05 lihaibh

@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 avatar May 27 '21 12:05 prabesh887

@prabesh887 you need winrar to extract the file

lihaibh avatar May 27 '21 12:05 lihaibh

@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?

prabesh887 avatar May 27 '21 14:05 prabesh887

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.

lihaibh avatar May 27 '21 15:05 lihaibh

@prabesh887 the issue resolved for you?

lihaibh avatar Jan 03 '23 19:01 lihaibh