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

Mongodump backup issue #56

Closed
necenzurat opened this issue Feb 11, 2016 · 12 comments
Closed

Mongodump backup issue #56

necenzurat opened this issue Feb 11, 2016 · 12 comments
Assignees
Labels

Comments

@necenzurat
Copy link

It seems i am having a issue with mongodump, i think the problem is at the

<?xml version="1.0" encoding="UTF-8"?>
<phpbu xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:noNamespaceSchemaLocation="http://schema.phpbu.de/3.0/phpbu.xsd"
       verbose="true">

  <logging>
    <log type="json" target="logfile.json"/>
  </logging>

  <backups>
    <backup>
      <!-- data to backup -->
      <!-- source mongodump -->
      <source type="mongodump">
        <option name="host" value="localhost"/>
        <option name="databases" value="all"/>

      </source>

      <!-- where should the backup be stored -->
        <target dirname="backup/" filename="mongodata-%Y%m%d-%H%i.bz2" compress="bzip2"/>


      <!-- do some sanity checks to make sure everything worked as planned -->
      <!-- <check type="sizemin" value="2M"/> -->

      <!-- sync backup to some location or service -->
      <sync type="amazons3">
        <option name="key" value="x"/>
        <option name="secret" value="x"/>
        <option name="bucket" value="x"/>
        <option name="region" value="us-east-1"/>
        <option name="path" value="back/%Y"/>
      </sync>

      <!-- deletes old backups -->
      <cleanup type="capacity">
        <option name="size" value="100M"/>
      </cleanup>
    </backup>
  </backups>
</phpbu>
Exception 'phpbu\App\Exception' with message 'Mongodump failed'
in phar:///usr/local/bin/phpbu/Backup/Source/Mongodump.php:163

backup mongodump: FAILED

Edit:
After some digging i foud this command, witch makes the error, generated by phpbu```
root@ip-172-31-63-218:/root# /usr/bin/mongodump --out '/root/backup/' --host 'localhost' --database 'status'
2016-02-11T03:44:41.287+0000 error parsing command line options: unknown option "database"
2016-02-11T03:44:41.287+0000 try 'mongodump --help' for more information

@necenzurat necenzurat changed the title Mongodump backup target issue Mongodump backup issue Feb 11, 2016
@sebastianfeldmann
Copy link
Owner

Hi, looks like the option should be --db instead of --database.
Could you please verify this by executing the command with the changed option.
If that's the case I will release a fix ASAP ;)

@sebastianfeldmann
Copy link
Owner

I have just released 3.0.2with a fix for the --db option
You can give it a try

$ phpbu --self-update
$ phpbu --simulate

@necenzurat
Copy link
Author

Offtopic for a bit, i have this line for the target

<target dirname="backup/mongo" filename="data-%Y%m%d-%H%i.json" compress="bzip2"/>

mongodump generates a "dump" folder with the databases inside,
mongorestore (to import) looks for the "dump" folder

i've successfully used phpbu on mongo with update 3.0.2, but after the archive was generated, when bzip2 -d it made a single file, witch it cannot be used for importing.

Thanks.

@sebastianfeldmann
Copy link
Owner

The final mongodump directory is getting compressed by the tar command.
You can extract it with this command

$ tar jxvf filename.tar.bz2

@necenzurat
Copy link
Author

but, how can i compress the whole dump directory?

@sebastianfeldmann
Copy link
Owner

If you specify a compressor like you did

<target dirname="backup" filename="mongodata-%Y%m%d-%H%i.dump" compress="bzip2"/>

You should see a file backup/mongodata-20160211-1530.dump.bz2

If not that's not good 😞

@necenzurat
Copy link
Author

the backup part it's ok but the restoring part worries me:
Restoring

ideally, when you extract the bz2 dump should result in a dump dir with the databases

@sebastianfeldmann
Copy link
Owner

The created mongodump directory is getting compressed with tar so it's getting compressed to a single file.

To uncompresse the file use.

$ tar jxvf mongodata-20160211-1427.dump.bz2

or

$ tar xvf mongodata-20160211-1427.dump

This should work ;)

@necenzurat
Copy link
Author

meh, that was my bad 😄
it would be nice if it would prepend the databases dir. would save the hard work of making a dump folder and putting the databases there in case of a restore.

thanks for the help.

@sebastianfeldmann
Copy link
Owner

You can easily do so with

$ mkdir dump && tar jxvf mongodata-20160211-1427.dump.bz2 -C dump

But I will have a look at the tar command, maybe I can include the compressed folder itself

@necenzurat
Copy link
Author

yea i know, but people, especially me are uber lazy.

@sebastianfeldmann
Copy link
Owner

I know the feeling ;)

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

No branches or pull requests

2 participants