Skip to content

Commit 24d6f26

Browse files
First stable mongoDB backup
1 parent 96a2f65 commit 24d6f26

File tree

6 files changed

+43
-5
lines changed

6 files changed

+43
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Get detailed information about all the features and a 'getting started' tutorial
1717

1818
* Creating backups
1919
+ Directories
20-
+ MongoDB (in progress)
20+
+ MongoDB
2121
+ MySQL
2222
+ PostgreSQL (planned)
2323
* Validate backups

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "PHP Backup utility.",
44
"type": "library",
55
"keywords": [
6-
"backup", "mysql", "tar", "cloud", "rsync", "sftp"
6+
"backup", "mysql", "mongodb", "tar", "cloud", "rsync", "sftp"
77
],
88
"homepage": "http://phpbu.de/",
99
"license": "BSD-3-Clause",

doc/config/source/mongodump.xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<source type="mongodump">
3+
<!-- optional, default=false -->
4+
<option name="showStdErr" value="true"/>
5+
6+
<!-- optional, default=localhost -->
7+
<option name="host" value="localhost"/>
8+
9+
<!-- optional, default=system user -->
10+
<option name="user" value="root"/>
11+
12+
<!-- optional, default=none -->
13+
<option name="password" value="secret"/>
14+
15+
<!-- optional, default=none -->
16+
<option name="authenticationDatabase" value="myAuthDB"/>
17+
18+
<!-- optional, default=all -->
19+
<option name="databases" value="myDB1,mydB2"/>
20+
21+
<!-- optional, default=all -->
22+
<option name="collections" value="myCollection1,myCollection2,myCollection3"/>
23+
24+
<!-- optional, default=none -->
25+
<option name="excludeCollections" value="myCollectionToExclude1,myCollectionToExclude2"/>
26+
27+
<!-- optional, default=none -->
28+
<option name="excludeCollectionsWithPrefix" value="myExcludePrefix1,myExcludePrefix2"/>
29+
30+
<!-- optional, default=false -->
31+
<option name="ipv6" value="true"/>
32+
</source>

src/Backup/Source/Mongodump.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public function backup(Target $target, Result $result)
191191
try {
192192
$tar = $this->getTar($target);
193193
$tar->backup($target, $result);
194-
// ToDo: remove dump directory
194+
$result->debug('remove dump directory');
195195
} catch (\Exception $e) {
196196
throw new Exception('Failed to \'tar\' Mongodump directory', 1, $e);
197197
}
@@ -265,7 +265,12 @@ public function getTar(Target $target)
265265
{
266266
if (null == $this->tar) {
267267
$this->tar = new Tar();
268-
$this->tar->setup(array('path' => $this->getDumpDir($target)));
268+
$this->tar->setup(
269+
array(
270+
'path' => $this->getDumpDir($target),
271+
'removeDir' => 'true',
272+
)
273+
);
269274
}
270275
return $this->tar;
271276
}

src/Factory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ abstract class Factory
3232
'mail' => '\\phpbu\\App\\Log\\Mail',
3333
),
3434
'source' => array(
35+
'mongodump' => '\\phpbu\\App\\Backup\\Source\\Mongodump',
3536
'mysqldump' => '\\phpbu\\App\\Backup\\Source\\Mysqldump',
3637
'tar' => '\\phpbu\\App\\Backup\\Source\\Tar',
3738
),

tests/phpbu/Backup/Source/MongodumpTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public function testBackupOk()
194194
->disableOriginalConstructor()
195195
->getMock();
196196

197-
$appResult->expects($this->once())->method('debug');
197+
$appResult->expects($this->exactly(2))->method('debug');
198198
$exec->expects($this->once())->method('execute')->willReturn($cliResult);
199199
$tar->expects($this->once())->method('backup');
200200

0 commit comments

Comments
 (0)