Last active
August 29, 2015 14:06
-
-
Save spolischook/08ebf9462ad9eb2bdeed to your computer and use it in GitHub Desktop.
Batch script for import mongo dump
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env php | |
| <?php | |
| require_once __DIR__.'/base_script.php'; | |
| $options = getopt("", array('db:', 'dir:')); | |
| $options['dir'] = !empty($options['dir']) ? $options['dir'] : "/"; | |
| $options['db'] = !empty($options['db']) ? $options['db']: "exercise"; | |
| $optionsLine = sprintf(" --dir=%s --db=%s", $options['dir'], $options['db']); | |
| foreach (scandir($options['dir']) as $file) { | |
| $pathParts = pathinfo($file); | |
| if ('bson' === $pathParts['extension']) { | |
| show_run( | |
| 'Import collection ' . $pathParts['filename'], | |
| sprintf('mongorestore -d %s -c %s %s.bson', $options['db'], $pathParts['filename'], $options['dir'] . $pathParts['filename']) | |
| ); | |
| } | |
| } | |
| exit(0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment