Code Duplication    Length = 11-16 lines in 8 locations

src/Backup/Source/Arangodump.php 1 location

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

src/Backup/Source/Elasticdump.php 1 location

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

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/Source/Tar.php 1 location

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

src/Backup/Source/XtraBackup.php 1 location

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

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.