Skip to content
Advertisement

Shell Script : MongoDB Dump

I’m creating a shell script to automatically dump the database. I have the current code below.

JavaScript

The problem is when I’m opening the zip file it shows a single binary file. Usually, when I dump manually it consists of bson and json files. I don’t know what I’m doing wrong I’m expecting a zip file with bson and json file.

UPDATE Turns out that –archive returns binary file. I updated the codes to:

JavaScript

The problem is how can I specifically tar the siaphaji-cms folder. The way it runs now is when its compressing it compress all inside backup folder.

Advertisement

Answer

That’s actually works as designed when you use --archive.

The alternative is to provide a path to --out, which will then give you individual BSON & JSON files … you’d have to manually GZIP those (or tar the resulting subdirectory/ies.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement