Exemplo n.º 1
0
    def run(self, runner):
        history = runner.publicPath("stub-meta-history.xml.gz")
        current = runner.publicPath("stub-meta-current.xml.gz")
        articles = runner.publicPath("stub-articles.xml.gz")
        for filename in (history, current, articles):
            if exists(filename):
                os.remove(filename)
        command = """
%s -q %s/maintenance/dumpBackup.php \
  --wiki=%s \
  --full \
  --stub \
  --report=10000 \
  %s \
  --server=%s \
  --output=gzip:%s \
  --output=gzip:%s \
	--filter=latest \
  --output=gzip:%s \
	--filter=latest \
	--filter=notalk \
	--filter=namespace:\!NS_USER \
""" % shellEscape((runner.config.php, runner.config.wikiDir, runner.dbName,
                   runner.forceNormalOption(), runner.dbServer, history,
                   current, articles))
        runner.runCommand(command, callback=self.progressCallback)
Exemplo n.º 2
0
 def buildFilters(self, runner):
     """Construct the output filter options for dumpTextPass.php"""
     xmlbz2 = self._path(runner, "bz2")
     if runner.config.bzip2[-6:] == "dbzip2":
         bz2mode = "dbzip2"
     else:
         bz2mode = "bzip2"
     return "--output=%s:%s" % shellEscape((bz2mode, xmlbz2))
Exemplo n.º 3
0
    def run(self, runner):
        command = """
%s -q %s/maintenance/dumpBackup.php \
  --wiki=%s \
  --plugin=AbstractFilter:%s/extensions/ActiveAbstract/AbstractFilter.php \
  --current \
  --report=1000 \
  %s \
  --server=%s \
""" % shellEscape((runner.config.php, runner.config.wikiDir,
                   runner.dbName, runner.config.wikiDir,
                   runner.forceNormalOption(), runner.dbServer))
        for variant in self._variants(runner):
            command = command + """  --output=file:%s \
    --filter=namespace:NS_MAIN \
    --filter=noredirect \
    --filter=abstract%s \
""" % shellEscape((runner.publicPath(
                self._variantFile(variant)), self._variantOption(variant)))
        command = command + "\n"
        runner.runCommand(command, callback=self.progressCallback)
Exemplo n.º 4
0
    def run(self, runner):
        logging = runner.publicPath("pages-logging.xml.gz")
        if exists(logging):
            os.remove(logging)
        command = """
%s -q %s/maintenance/dumpBackup.php \
  --wiki=%s \
  --logs \
  --report=10000 \
  %s \
  --server=%s \
  --output=gzip:%s \
""" % shellEscape((runner.config.php, runner.config.wikiDir, runner.dbName,
                   runner.forceNormalOption(), runner.dbServer, logging))
        runner.runCommand(command, callback=self.progressCallback)
Exemplo n.º 5
0
    def run(self, runner):
        if runner.lastFailed:
            raise BackupError("bz2 dump incomplete, not recompressing")

        xmlbz2 = self._path(runner, "bz2")
        xml7z = self._path(runner, "7z")

        # Clear prior 7zip attempts; 7zip will try to append an existing archive
        if exists(xml7z):
            os.remove(xml7z)

        # temp hack force 644 permissions until ubuntu bug # 370618 is fixed - tomasz 5/1/2009
        command = "%s -dc < %s | %s a -si %s ; chmod 644 %s" % shellEscape(
            (runner.config.bzip2, xmlbz2, runner.config.sevenzip, xml7z,
             xml7z))

        return runner.runCommand(command, callback=self.progressCallback)
Exemplo n.º 6
0
 def cleanOldDumps(self):
     old = self.wiki.dumpDirs()
     if old:
         if old[-1] == self.date:
             # If we're re-running today's dump, don't count it as one
             # of the old dumps to keep... or delete it halfway through!
             old = old[:-1]
         if self.config.keep > 0:
             # Keep the last few
             old = old[:-(self.config.keep)]
     if old:
         for dump in old:
             self.status("Purging old dump %s for %s" % (dump, self.dbName))
             base = os.path.join(self.wiki.publicDir(), dump)
             command = "rm -rf %s" % shellEscape(base)
             self.runCommand(command)
     else:
         self.status("No old dumps to purge.")
Exemplo n.º 7
0
    def buildCommand(self, runner):
        """Build the command line for the dump, minus output and filter options"""

        # Page and revision data pulled from this skeleton dump...
        stub = runner.publicPath("stub-%s.xml.gz" % self._subset),
        stubOption = "--stub=gzip:%s" % stub

        # Try to pull text from the previous run; most stuff hasn't changed
        #Source=$OutputDir/pages_$section.xml.bz2
        if self._prefetch:
            source = self._findPreviousDump(runner)
        else:
            source = None
        if source and exists(source):
            runner.status(
                "... building %s XML dump, with text prefetch from %s..." %
                (self._subset, source))
            prefetch = "--prefetch=bzip2:%s" % (source)
        else:
            runner.status("... building %s XML dump, no text prefetch..." %
                          self._subset)
            prefetch = None

        if self._spawn:
            spawn = "--spawn=%s" % (runner.config.php)
        else:
            spawn = None

        dumpCommand = """
%s -q %s/maintenance/dumpTextPass.php \
  --wiki=%s \
  %s \
  %s \
  %s \
  --report=1000 \
  --server=%s \
  %s""" % shellEscape((runner.config.php, runner.config.wikiDir,
                       runner.dbName, stubOption, prefetch,
                       runner.forceNormalOption(), runner.dbServer, spawn))
        command = dumpCommand
        return command
Exemplo n.º 8
0
 def defaultServer(self):
     command = "%s -q %s/maintenance/getSlaveServer.php --wiki=%s --group=dump" % shellEscape(
         (self.config.php, self.config.wikiDir, self.dbName))
     return self.runAndReturn(command).strip()
Exemplo n.º 9
0
 def saveCommand(self, command, outfile, pipe=False):
     """Shell out and redirect output to a given file."""
     return self.runCommand(command + " > " + shellEscape(outfile), pipe)
Exemplo n.º 10
0
 def saveSql(self, query, outfile):
     """Pass some SQL commands to the server for this DB and save output to a file."""
     command = "echo %s | mysql -h %s -u %s %s %s -r | gzip" % shellEscape(
         (query, self.dbServer, self.config.dbUser, self.passwordOption(),
          self.dbName))
     return self.saveCommand(command, outfile, pipe=True)
Exemplo n.º 11
0
 def saveTable(self, table, outfile):
     """Dump a table from the current DB with mysqldump, save to a gzipped sql file."""
     command = "mysqldump -h %s -u %s %s --opt --quick --skip-add-locks --skip-lock-tables %s %s | gzip" % shellEscape(
         (self.dbServer, self.config.dbUser, self.passwordOption(),
          self.dbName, self.getDBTablePrefix() + table))
     return self.saveCommand(command, outfile, pipe=True)
Exemplo n.º 12
0
 def getDBTablePrefix(self):
     """Get the prefix for all tables for the specific wiki ($wgDBprefix)"""
     command = "echo 'print $wgDBprefix; ' | %s -q %s/maintenance/eval.php --wiki=%s" % shellEscape(
         (self.config.php, self.config.wikiDir, self.dbName))
     return self.runAndReturn(command).strip()