file_put_contents($backupFolder . '.tar.gz', gzencode(file_get_contents($backupFolder . '.tar'), 9));
            fwrite(STDERR, "Compresion complete!" . PHP_EOL);
            fwrite(STDERR, "Removing temp folders and files.." . PHP_EOL);
            //remove other files
            unlink(realpath($backupFolder . '.tar'));
            deleteDir(realpath($backupFolder));
            fwrite(STDERR, "Temp folders and files removed!" . PHP_EOL);
        }
    } catch (Exception $e) {
        fwrite(STDERR, "{$e}" . PHP_EOL);
    }
    return;
    //exit(1);
} else {
    $dumper = new Dumper($host, $port, $database, $noHistory, $callbackFile, $inlineAttachment, $binaryAttachments, $prettyJsonOutput, $separateFiles, $timeStamp, $callbackFilter);
    $dumper->download();
}
function deleteDir($dirPath)
{
    if (!is_dir($dirPath)) {
        throw new InvalidArgumentException("{$dirPath} must be a directory");
    }
    if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') {
        $dirPath .= '/';
    }
    $files = glob($dirPath . '*', GLOB_MARK);
    foreach ($files as $file) {
        if (is_dir($file)) {
            deleteDir($file);
        } else {
            unlink($file);