dokku / dokku-mongo

a mongo plugin for dokku
MIT License
174 stars 32 forks source link

How would import the backup generated by this into a local instance? #82

Closed aforty closed 7 years ago

aforty commented 7 years ago

I can't seem to figure out what the command is to import the resulting tgz file locally. Anyone have a quick answer?

aforty commented 7 years ago

Actually I figured it out because when I do a manual export I get a tar file that contains all the json files. However I have a scheduled backup to S3 but there all the tgz files only contains a file export (backup/export) which I cannot seem to figure out how to import.

Thoughts?

aforty commented 7 years ago

So apparently that export file is a tar file but without the extension, untaring that gave me the json files I was after. This is super confusing, is there any way the tgz file that ends up on s3 just contains the json files in it?

josegonzalez commented 7 years ago

No, the export uses the format it uses as otherwise that is how the import works. You'll need to have your tooling decompress the file before importing the json contents.

bradwbradw commented 7 years ago

@aforty could you please paste the command you used to extract JSON from the tar file?

I'm trying tar -xvf mongo.tar but it fails with "unrecognized format"

here's more of my steps

ssh dokku@example.com mongo:export xyz > ~/mongo.tar
Connection to example.com closed.
tar -xvf mongo.tar 
tar: Unrecognized archive format
tar: Error exit delayed from previous errors.
aforty commented 7 years ago
dokku mongo:export xyz > mongo-backup.tgz
tar xvf mongo-backup.tgz
bradwbradw commented 7 years ago

Thanks. I realized the problem. it's because I was using a remote command. You are probably already SSH'd in when you call dokku mongo:export ..., whereas i was using ssh dokku@example.com mongo:export ...

the problem is that when using a remote command, the tar file has the verbose output from the command concatenated to the top, eg

2017-05-24T19:36:24.433+0000    writing xyz.SpaceSong to 
                                                                                                                 2017-05-24T19:36:24.434+0000   writing xyz.Song to 
                                            2017-05-24T19:36:24.435+0000    writing xyz.dj to 
                                                                                                  2017-05-24T19:36:24.436+0000  done dumping xyz.RoleMapping (11 documents)

(i don't know why it has strange line breaks)

bradwbradw commented 7 years ago

i created this issue to capture the remote command problem: https://github.com/dokku/dokku-mongo/issues/84