move all existing in subfolders
This commit is contained in:
1 parent
cc069f63ef
commit
6491336e60
48 files changed
No files matched your search
@@ -0,0 +1,3 @@
|
||||
This folder hast to be on the SBZ server
|
||||
|
||||
The credentials.php has to be filled but never commited to the git
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
$dumps_path = 'dumps/';
|
||||
if(file_exists($dumps_path))
|
||||
{
|
||||
array_map( 'unlink', array_filter((array) glob($dumps_path.'*') ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
mkdir('dumps');
|
||||
}
|
||||
|
||||
$host = 'localhost';
|
||||
$user = 'root';
|
||||
$pass = "AdfQ3prfUDPu2MtaoLFtxvWbdBooJ6";
|
||||
|
||||
$db_conn = new mysqli($host, $user, $pass);
|
||||
|
||||
$result = mysqli_query($db_conn,"SHOW DATABASES");
|
||||
while ($row = mysqli_fetch_array($result)) {
|
||||
|
||||
if($row[0] == 'information_schema' || $row[0] == 'performance_schema')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$database = $row[0];
|
||||
$dir = dirname(__FILE__) . '/'.$dumps_path.$database.'.sql';
|
||||
|
||||
exec("mysqldump --user={$user} --password={$pass} --host={$host} {$database} --result-file={$dir} 2>&1", $output);
|
||||
if(!empty($output))
|
||||
{
|
||||
var_dump($output);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
## Zip all dumps
|
||||
$zipfile = "dumps.zip";
|
||||
|
||||
if(file_exists($zipfile))
|
||||
{
|
||||
unlink($zipfile);
|
||||
}
|
||||
$zip = new ZipArchive;
|
||||
if($zip -> open($zipfile, ZipArchive::CREATE ) === TRUE)
|
||||
{
|
||||
$dir = opendir($dumps_path);
|
||||
while($file = readdir($dir)) {
|
||||
if(is_file($dumps_path.$file)) {
|
||||
$zip -> addFile($dumps_path.$file, $file);
|
||||
}
|
||||
}
|
||||
$zip ->close();
|
||||
}
|
||||
Reference in new issue
Block a user