class Pman_Admin_Dump extends Pman {
+ static $cli_desc = "Dump database ?/ needs more info...";
+
+
function getAuth()
{
var $deps = array(); // list of dependants
var $out = array(); // list of created sql/shell scripts.
- function get($path )
+ function get($path, $opts = Array() )
{
ini_set('memory_limit', '256M'); // we need alot of memory
set_time_limit(0);
array_shift($argv);
array_shift($argv);
- $opts = explode(',', 'table==,where==,dump-dir==,dump-dir==,debug=');
+ $opts = explode(',', 'table==,where==,dump-dir==,debug=');
require_once 'Console/Getopt.php';
$go = Console_Getopt::getopt2($argv, '', $opts );
if (is_object($go)) {
if (empty($ar)) { continue; }
echo " " .$tbl . ' -> ' . count(array_keys($ar)) . " Records\n";
}
+ echo "FILES:\n";
+ echo " Total : " . $this->filetotal . " files using " . floor($this->filesize/1000000) . "Mb\n";
+
echo "GENERATED FILES:\n";
// summary
echo " ". implode("\n ", $this->out). "\n";
var $dscan = array(); // TABLE:COL => [value => TRUE|FALSE] - if its been scanned..
var $childfiles = array(); // array of [ 'sourcedirectory' , 'subdirectory(s) and filename' ]
var $childthumbs = array(); // array of [ 'filename', 'filename' ,......]
+ var $filesize = 0; // size of files to be saved. (not total deletd..)
+ var $filetotal = 0; // number of distinct files to be saved (not total deleted)
/**
* scan table for
* a) what depends on it (eg. child elements) - which will be deleted.
$this->out[] = $target;
$fh3 = fopen($target, 'w');
- $fs = 0;
+
+ $done = array();
+ $donedir = array();
foreach($this->childfiles as $v) {
- $fs += filesize($v[0].'/'.$v[1]);
- fwrite($fh,"mkdir -p " . escapeshellarg(dirname($this->args['dump-dir'] .'/'.$v[1])) ."\n" );
+
+ if (isset($done[$v[1]])) {
+ continue;
+ }
+
+ $done[$v[1]] = true;
+
+ $this->filesize += filesize($v[0].'/'.$v[1]);
+ $this->filetotal++;
+ $fdir = dirname($this->args['dump-dir'] .'/'.$v[1]);
+ if (!isset($donedir[$fdir])) {
+ fwrite($fh,"mkdir -p " . escapeshellarg(dirname($this->args['dump-dir'] .'/'.$v[1])) ."\n" );
+ }
fwrite($fh,"cp " . escapeshellarg($v[0].'/'.$v[1]) . ' ' . escapeshellarg($this->args['dump-dir'] .'/'.$v[1]) ."\n" );
+ if (!isset($donedir[$fdir])) {
+ fwrite($fh3,"mkdir -p " . escapeshellarg(dirname($v[0].'/'.$v[1])) ."\n" );
+ }
+ $donedir[$fdir] = true;
- fwrite($fh3,"mkdir -p " . escapeshellarg(dirname($v[0].'/'.$v[1])) ."\n" );
fwrite($fh3,"cp " . escapeshellarg($this->args['dump-dir'] .'/'.$v[1]) . ' ' . escapeshellarg($v[0].'/'.$v[1]) . "\n" );
-
fwrite($fh2,"rm " . escapeshellarg($v[0].'/'.$v[1]) ."\n" );
}
fclose($fh);
fclose($fh3); // restore does not need to bother with thumbnails.
-
- $this->fs = $fs;
+
foreach($this->childthumbs as $v) {