Code Duplication    Length = 11-16 lines in 8 locations

src/Backup/Source/Mongodump.php 1 location

@@ 155-167 (lines=13) @@
152
     * @return \phpbu\App\Backup\Source\Status
153
     * @throws \phpbu\App\Exception
154
     */
155
    public function backup(Target $target, Result $result) : Status
156
    {
157
        // setup dump location and execute the dump
158
        $mongodump = $this->execute($target);
159
160
        $result->debug($mongodump->getCmdPrintable());
161
162
        if (!$mongodump->isSuccessful()) {
163
            throw new Exception('mongodump failed: ' . $mongodump->getStdErr());
164
        }
165
166
        return $this->createStatus($target);
167
    }
168
169
    /**
170
     * Create the Executable to run the Mongodump command.

src/Backup/Source/Pgdump.php 1 location

@@ 242-253 (lines=12) @@
239
     * @return \phpbu\App\Backup\Source\Status
240
     * @throws \phpbu\App\Exception
241
     */
242
    public function backup(Target $target, Result $result) : Status
243
    {
244
245
        $pgDump = $this->execute($target);
246
        $result->debug($pgDump->getCmdPrintable());
247
248
        if (!$pgDump->isSuccessful()) {
249
            throw new Exception('mysqldump failed:' . $pgDump->getStdErr());
250
        }
251
252
        return $this->createStatus($target);
253
    }
254
255
    /**
256
     * Create the Executable to run the mysqldump command.

src/Backup/Source/Rsync.php 1 location

@@ 47-57 (lines=11) @@
44
     * @return \phpbu\App\Backup\Source\Status
45
     * @throws \phpbu\App\Exception
46
     */
47
    public function backup(Target $target, Result $result) : Status
48
    {
49
        $rsync = $this->execute($target);
50
        $result->debug($rsync->getCmd());
51
52
        if (!$rsync->isSuccessful()) {
53
            throw new Exception('rsync failed:' . $rsync->getStdErr());
54
        }
55
56
        return $this->createStatus($target);
57
    }
58
59
    /**
60
     * Setup the Executable to run the 'rsync' command.

src/Backup/Sync/Rsync.php 1 location

@@ 50-64 (lines=15) @@
47
     * @param  \phpbu\App\Result        $result
48
     * @throws \phpbu\App\Backup\Sync\Exception
49
     */
50
    public function sync(Target $target, Result $result)
51
    {
52
        if ($this->args) {
53
            // pro mode define all arguments yourself
54
            // WARNING! no escaping is done by phpbu
55
            $result->debug('WARNING: phpbu uses your rsync args without escaping');
56
        }
57
        $rsync = $this->execute($target);
58
59
        $result->debug($rsync->getCmd());
60
61
        if (!$rsync->isSuccessful()) {
62
            throw new Exception('rsync failed: ' . $rsync->getStdErr());
63
        }
64
    }
65
66
    /**
67
     * Simulate the sync execution.

src/Backup/Source/Arangodump.php 1 location

@@ 139-150 (lines=12) @@
136
     * @return \phpbu\App\Backup\Source\Status
137
     * @throws \phpbu\App\Exception
138
     */
139
    public function backup(Target $target, Result $result) : Status
140
    {
141
        $arangodump = $this->execute($target);
142
143
        $result->debug($arangodump->getCmdPrintable());
144
145
        if (!$arangodump->isSuccessful()) {
146
            throw new Exception('arangodump failed: ' . $arangodump->getStdErr());
147
        }
148
149
        return $this->createStatus($target);
150
    }
151
152
    /**
153
     * Create the Executable to run the arangodump command.

src/Backup/Source/Elasticdump.php 1 location

@@ 104-115 (lines=12) @@
101
     * @return \phpbu\App\Backup\Source\Status
102
     * @throws \phpbu\App\Exception
103
     */
104
    public function backup(Target $target, Result $result) : Status
105
    {
106
        $elasticdump = $this->execute($target);
107
108
        $result->debug($elasticdump->getCmdPrintable());
109
110
        if (!$elasticdump->isSuccessful()) {
111
            throw new Exception('elasticdump failed: ' . $elasticdump->getStdErr());
112
        }
113
114
        return $this->createStatus($target);
115
    }
116
117
    /**
118
     * Create the Executable to run the elasticdump command.

src/Backup/Source/Tar.php 1 location

@@ 137-152 (lines=16) @@
134
     * @return \phpbu\App\Backup\Source\Status
135
     * @throws \phpbu\App\Exception
136
     */
137
    public function backup(Target $target, Result $result) : Status
138
    {
139
        // make sure source path is a directory
140
        $this->validatePath();
141
        // set uncompressed default MIME type
142
        $target->setMimeType('application/x-tar');
143
        $tar = $this->execute($target);
144
145
        $result->debug($tar->getCmdPrintable());
146
147
        if (!$tar->isSuccessful()) {
148
            throw new Exception('tar failed: ' . $tar->getStdErr());
149
        }
150
151
        return $this->createStatus($target);
152
    }
153
154
    /**
155
     * Setup the Executable to run the 'tar' command.

src/Backup/Source/XtraBackup.php 1 location

@@ 118-129 (lines=12) @@
115
     * @return \phpbu\App\Backup\Source\Status
116
     * @throws \phpbu\App\Exception
117
     */
118
    public function backup(Target $target, Result $result) : Status
119
    {
120
        $innobackupex = $this->execute($target);
121
122
        $result->debug($this->getExecutable($target)->getCommandPrintable());
123
124
        if (!$innobackupex->isSuccessful()) {
125
            throw new Exception('XtraBackup failed: ' . $innobackupex->getStdErr());
126
        }
127
128
        return $this->createStatus($target);
129
    }
130
131
    /**
132
     * Create the Executable to run the innobackupex backup and apply-log commands.