Skip to content
This repository was archived by the owner on Feb 3, 2022. It is now read-only.

Commit 30c8467

Browse files
committed
Merge branch 'release/1.4.1'
2 parents 31e46b2 + b675468 commit 30c8467

File tree

5 files changed

+79
-8
lines changed

5 files changed

+79
-8
lines changed

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ It's design to run on production boxes to create database dumps and upload to Am
66

77
It can then be run on local development machines to get latest or specific backup for a project and automatically import it.
88

9+
Works particularly well when partnered with [mageconfigsync](https://github.com/punkstar/mageconfigsync).
10+
911
## Motivation
1012

1113
Working on Magento client sites typically requires a fresh copy of the production database in order reduce discrepencies later in the development cycle due to differences between environments. This can be difficult to achieve a number of reasons and either way will slow down development process.
@@ -122,3 +124,47 @@ Delete old backups from S3.
122124
```
123125
magedbm rm [-r|--region="..."] [-b|--bucket="..."] name file
124126
```
127+
128+
129+
## Development
130+
131+
### Packaging Phar
132+
133+
We use [box project](https://github.com/box-project/box2) for creating a phar. The configuration for which is found in
134+
`box.json`.
135+
136+
To build, change to the project root and run:
137+
138+
```
139+
box build
140+
```
141+
142+
If you run into the following [error](https://github.com/box-project/box2/issues/80):
143+
144+
```
145+
PHP Fatal error: Uncaught exception 'ErrorException' with message 'proc_open(): unable to create pipe Too many open files'
146+
```
147+
148+
149+
Then increasing the limit by running this seems to be a solid workaround:
150+
151+
```
152+
ulimit -Sn 4096
153+
```
154+
155+
### Creating Release
156+
157+
After creating a release according to [meanbee standards](http://standards.meanbee.com/tools.html), the phar can be attached to the release on github.
158+
159+
It also needs to be uploaded to the magedbm-releases bucket in Meanbee's S3 account. We upload one version as `magedbm.phar` and another with the version in it `magedbm.1.3.0.phar`.
160+
161+
In order for the self-update command to know about the new release, the manifest.json file (also in the magedbm-releases bucket) requires update. Create a new entry in the releases array to point to the latest version. To create the SHA which is used for valiation upon update run this command:
162+
163+
```
164+
shasum -a 1 ./magedbm.phar
165+
```
166+
167+
For any files uploaded, make sure that they're made public by clicking on Properties so that external uses to Meanbee can access.
168+
169+
170+

manifest.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[
2+
{
3+
"name": "magedbm.phar",
4+
"sha1": "378a6ca3e92f850508900415e2c905387a0d940c",
5+
"url": "https://s3-eu-west-1.amazonaws.com/magedbm-releases/magedbm.1.3.2.phar",
6+
"version": "1.3.2"
7+
},
8+
{
9+
"name": "magedbm.phar",
10+
"sha1": "1830c419f4d7043a15ae88c5ded6bd834b656fc3",
11+
"url": "https://s3-eu-west-1.amazonaws.com/magedbm-releases/magedbm.1.4.0.phar",
12+
"version": "1.4.0"
13+
}
14+
]
15+

src/Meanbee/Magedbm/Application.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Application extends \Symfony\Component\Console\Application
1212
{
1313

1414
const APP_NAME = 'Magedbm';
15-
const APP_VERSION = '1.4.0';
15+
const APP_VERSION = '1.4.1';
1616

1717
protected $autoloader;
1818

@@ -43,4 +43,4 @@ public function setAutoloader($autoloader)
4343

4444
return $this;
4545
}
46-
}
46+
}

src/Meanbee/Magedbm/Command/GetCommand.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ protected function downloadBackup($file, $s3, $config, $input)
166166
'SaveAs' => $this->getFilePath($file)
167167
));
168168
} catch (NoSuchKeyException $e) {
169-
$this->getOutput()->writeln('<error>File such file found in S3 bucket.</error>');
169+
$this->getOutput()->writeln('<error>No such file found in S3 bucket.</error>');
170170
exit;
171171
}
172172

@@ -218,8 +218,16 @@ protected function backupMove($file)
218218
{
219219
$filename = $this->getFilePath($file);
220220
$newFilename = getcwd() . '/' . $file;
221-
if (rename($filename, $newFilename)) {
222-
$this->getOutput()->writeln("<info>Downloaded to $newFilename.</info>");
221+
222+
if (!is_writable(getcwd())) {
223+
$this->getOutput()->writeln("<info>Unable to write to current working directory. Check $filename</info>");
224+
return;
225+
}
226+
227+
$result = rename($filename, $newFilename);
228+
229+
if ($result && file_exists($newFilename)) {
230+
$this->getOutput()->writeln("<info>Downloaded to $newFilename</info>");
223231
} else {
224232
$this->getOutput()->writeln("<error>Failed to move backup to current working directory. Check $filename</error>");
225233
}
@@ -250,4 +258,4 @@ protected function cleanUp()
250258
{
251259
array_map('unlink', glob(self::TMP_PATH . '/*'));
252260
}
253-
}
261+
}

src/Meanbee/Magedbm/Command/PutCommand.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ protected function maintainDatabaseHistory($input, $output, $s3, $config)
123123
try {
124124
$results = $s3->getIterator(
125125
'ListObjects',
126-
array('Bucket' => $config['bucket'], 'Prefix' => $input->getArgument('name'), 'sort_results' => true)
126+
array('Bucket' => $config['bucket'], 'Prefix' => $input->getArgument('name') . '/', 'sort_results' => true)
127127
);
128128

129129
$results = iterator_to_array($results, true);
@@ -210,7 +210,7 @@ private function createBackup(InputInterface $input, OutputInterface $output)
210210
$magerun = $this->getMagerun();
211211
$filePath = $this->getFilePath($input);
212212

213-
$stripOptions = $input->getOption('strip') ? : '@development';
213+
$stripOptions = $input->getOption('strip') ?: '@development';
214214

215215
// Exec must be unavailable so use PHP alternative (match output)
216216
$dbHelper = new DatabaseHelper();
@@ -258,6 +258,7 @@ private function createBackup(InputInterface $input, OutputInterface $output)
258258
'include-tables' => $stripTables,
259259
'no-data' => true,
260260
'add-drop-table' => true,
261+
'skip-triggers' => true,
261262
)
262263
);
263264

@@ -266,6 +267,7 @@ private function createBackup(InputInterface $input, OutputInterface $output)
266267
$dump = new Mysqldump(sprintf('%s;dbname=%s', $dbHelper->dsn(), $dbName), $username, $password, array(
267268
'exclude-tables' => $stripTables,
268269
'add-drop-table' => true,
270+
'skip-triggers' => true,
269271
));
270272

271273
$dump->start($filePath . '.data');

0 commit comments

Comments
 (0)