Build Tar file from directory in PHP without exec/passthru

UnkwnTech picture UnkwnTech · Dec 2, 2008 · Viewed 16.2k times · Source

So I have a client who's current host does not allow me to use tar via exec()/passthru()/ect and I need to backup the site periodicly and programmaticly so is there a solution?

This is a linux server.

Answer

naitsirch picture naitsirch · Jul 6, 2011

PHP 5.3 offers a much easier way to solve this issue.

Look here: http://www.php.net/manual/en/phardata.buildfromdirectory.php

<?php
$phar = new PharData('project.tar');
// add all files in the project
$phar->buildFromDirectory(dirname(__FILE__) . '/project');
?>