Mongodump backup issue #56

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

Comments

Projects
None yet
2 participants
@necenzurat

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 from Mongodump backup target issue to Mongodump backup issue Feb 11, 2016

@sebastianfeldmann

This comment has been minimized.

Show comment
Hide comment
@sebastianfeldmann

sebastianfeldmann Feb 11, 2016

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

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

This comment has been minimized.

Show comment
Hide comment
@sebastianfeldmann

sebastianfeldmann Feb 11, 2016

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

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

This comment has been minimized.

Show comment
Hide comment
@necenzurat

necenzurat Feb 11, 2016

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.

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

This comment has been minimized.

Show comment
Hide comment
@sebastianfeldmann

sebastianfeldmann Feb 11, 2016

Owner

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

$ tar jxvf filename.tar.bz2

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

$ tar jxvf filename.tar.bz2
@necenzurat

This comment has been minimized.

Show comment
Hide comment
@necenzurat

necenzurat Feb 11, 2016

but, how can i compress the whole dump directory?

but, how can i compress the whole dump directory?

@sebastianfeldmann

This comment has been minimized.

Show comment
Hide comment
@sebastianfeldmann

sebastianfeldmann Feb 11, 2016

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 😞

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

This comment has been minimized.

Show comment
Hide comment
@necenzurat

necenzurat Feb 11, 2016

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

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

This comment has been minimized.

Show comment
Hide comment
@sebastianfeldmann

sebastianfeldmann Feb 11, 2016

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

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

This comment has been minimized.

Show comment
Hide comment
@necenzurat

necenzurat Feb 11, 2016

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.

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

This comment has been minimized.

Show comment
Hide comment
@sebastianfeldmann

sebastianfeldmann Feb 11, 2016

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

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

This comment has been minimized.

Show comment
Hide comment
@necenzurat

necenzurat Feb 11, 2016

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

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

@sebastianfeldmann

This comment has been minimized.

Show comment
Hide comment
@sebastianfeldmann

sebastianfeldmann Feb 11, 2016

Owner

I know the feeling ;)

I know the feeling ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment