protected function checkDumpDir()
    {

        if (!is_dir($this->dump_dir)) {
            mkdir($this->dump_dir, 0700, true);
        }

        foreach (\range($this->max_version, 1) as $version) {
            $dir = $this->dump_dir . $version;

            if (is_dir($dir)) {

                if ($version == $this->max_version) {
                    $this->recursiveDelete($dir, 1);
                    $this->log('Deleting backup ' . $this->max_version);
                } else {
                    $new_version = $version + 1;
                    rename($dir, $this->dump_dir . $new_version);
                    $this->log('Moving backup ' . $version . ' to version ' . $new_version);
                }
            }
        }

        if (!is_dir($this->dump_dir . '1')) {
            mkdir($this->dump_dir . '1', 0700, true);
        }
    }