Page MenuHomePhabricator
Authored By
CDanis
Aug 1 2019, 9:29 PM
Size
1 KB
Referenced Files
None
Subscribers
None
#!/usr/bin/php
<?php
// This script takes dbctl-JSON-formatted configuration, as produced by e.g.
// dbctl -s eqiad config get
// and transforms it into PHP suitable for pasting into db-eqiad.php in an
// emergency.
// It can also read the JSON 'restore' files output by dbctl config commit,
// with some help from jq:
// jq '.eqiad' /var/cache/conftool/dbconfig/FOO.json
$argc == 2 or die("usage: $argv[0] INPUT-JSON-FILE\n");
$inputfilename = $argv[1] or die;
$data = json_decode(file_get_contents($inputfilename), TRUE);
$data != NULL or die;
$readOnlyBySection = $data['readOnlyBySection'];
$groupLoadsBySection = $data['groupLoadsBySection'];
$sectionLoads = [];
foreach ($data['sectionLoads'] as $section => $loads) {
$sectionLoads[$section] = array_merge($loads[0], $loads[1]);
}
print '$wgLBFactoryConf[\'sectionLoads\'] = ';
var_export($sectionLoads);
print ";\n";
print '$wgLBFactoryConf[\'readOnlyBySection\'] = ';
var_export($readOnlyBySection);
print ";\n";
print '$wgLBFactoryConf[\'groupLoadsBySection\'] = ';
var_export($groupLoadsBySection);
print ";\n";

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
7807695
Default Alt Text
raw.txt (1 KB)

Event Timeline