Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backup.tar file invalid #18

Open
prabesh887 opened this issue May 7, 2021 · 8 comments
Open

backup.tar file invalid #18

prabesh887 opened this issue May 7, 2021 · 8 comments

Comments

@prabesh887
Copy link

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.

@lihaibh
Copy link
Owner

lihaibh commented May 7, 2021

how did you create this tar?

@prabesh887
Copy link
Author

prabesh887 commented May 8, 2021

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}`);
}

}

@lihaibh
Copy link
Owner

lihaibh commented May 27, 2021

@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

@prabesh887
Copy link
Author

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

@lihaibh
Copy link
Owner

lihaibh commented May 27, 2021

@prabesh887 you need winrar to extract the file

@prabesh887
Copy link
Author

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

@lihaibh
Copy link
Owner

lihaibh commented May 27, 2021

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
Copy link
Owner

lihaibh commented Jan 3, 2023

@prabesh887 the issue resolved for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants