public function dump($id) {
        if (VERBOSE) echo "  DUMP $id" ,PHP_EOL;
        $filename = $this->dumps_dir . 'dump-' . $id . '.tar.gz';
        if (file_exists($filename)) {
            // skip
            if (VERBOSE) echo "   SKIPPING : $filename exists" ,PHP_EOL;
            return false;
        } else {
            try {
                $tgz_data = $this->api->api("/reports/dump/{$id}.tgz", 'GET');
            } catch (Exception $e) {
                throw new Exception('Could not find dump with id '.$id);
                exit;
            }
            file_put_contents($filename, $tgz_data);
        }
        $unpacked_files = array();
        chdir(dirname($filename));
        if (exec("/bin/tar -zxvf $filename -C ".$this->tmp_dir, $output)) {


            $injects = array();
            foreach ($output as $file) {
                $thisFile = $this->tmp_dir . $file;
                $unpacked_files[] = $thisFile;
                if (file_exists($thisFile)) {
                    list($model, ) = explode('-', $file);

                    if (isset($this->modelsToTable[$model])) {
                        $table = $this->modelsToTable[$model];
                    } else {
                        // or auto guess?
                        if (DEBUG) echo "   SKIPPING $model : table not found!" ,PHP_EOL;
                        continue;
                    }
                    $sql = "LOAD DATA INFILE '$thisFile' REPLACE INTO TABLE $table CHARACTER SET utf8 IGNORE 1 LINES";
                    if (DEBUG) echo PHP_EOL, 'DEBUG : $sql : ' . $sql, PHP_EOL;
                    $this->db->query($sql);
                }
            }
        } else {
            throw new Exception('File uncompression failed for file ' . $filename);
        }
        foreach ($unpacked_files as $file) {
           unlink($file);
        }
        return true;
    }