0xV3NOMx
Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64



Your IP : 3.22.68.29


Current Path : /var/www/html/univadmin/
Upload File :
Current File : /var/www/html/univadmin/backup1.php

<?php

	ini_set('memory_limit','-1');
	ini_set('display_errors', 1);
	ini_set('max_execution_time', 800);
	
	require_once("../aws/aws-autoloader.php");
	use Aws\S3\S3Client;
	use Aws\S3\Exception\S3Exception;
   
	include("/var/www/config.php");
	$servername = SERVERNAME;
	$username   = USERNAME;
	$password  = PASSWORD;


   	$conn= new  mysqli($dbhost,$dbuser,$dbpass);
	if(!$conn) 
	{
			die("Connection failed: " . mysqli_connect_error());
	}

	$sql ="SHOW DATABASES"; 
	$result = $conn->query($sql);
	while($row = $result->fetch_assoc())
	{

			if($row['Database']!= "information_schema" && 
                   $row['Database']!= "mysql"&&
                   $row['Database']!= "performance_schema"&&
                   $row['Database']!= "phpmyadmin"&&
				   $row['Database']!= "logisys3_comexam"&&
				   $row['Database']!= "logisys3_gug"&&
				   $row['Database']!= "logisys3_gug_bkp"&&
                   $row['Database']!= "logisys3_bkp"&&
                   $row['Database']!= "logisys3_demo"&&
                   $row['Database']!= "logisys3_aims_bkp"&&
                   $row['Database']!= "logisys3_bcu_bkp"&&
                   $row['Database']!= "logisys3_bnu_bkp"&&
                   $row['Database']!= "logisys3_dud_bkp"&&
                   $row['Database']!= "logisys3_gach_bkp"&&
                   $row['Database']!= "logisys3_gcc_bkp"&&
                   $row['Database']!= "logisys3_gcg_bkp"&&
                   $row['Database']!= "logisys3_gcm_bkp"&&
                   $row['Database']!= "logisys3_gcw_bkp"&&
                   $row['Database']!= "logisys3_gfgcg_bkp"&&
                   $row['Database']!= "logisys3_gsc_bkp"&&
                   $row['Database']!= "logisys3_gsh_bkp"&&
                   $row['Database']!= "logisys3_jssm_bkp"&&
                   $row['Database']!= "logisys3_jssu_bkp"&&
                   $row['Database']!= "logisys3_jssw_bkp"&&
                   $row['Database']!= "logisys3_kswu_bkp"&&
                   $row['Database']!= "logisys3_kus_bkp"&&
                   $row['Database']!= "logisys3_kusd_bkp"&&
                   $row['Database']!= "logisys3_mcu_bkp"&&
                   $row['Database']!= "logisys3_mum_bkp"&&
                   $row['Database']!= "logisys3_nehu_bkp"&&
                   $row['Database']!= "logisys3_nitte_bkp"&&
                   $row['Database']!= "logisys3_rcu_bkp"&&
                   $row['Database']!= "logisys3_reva_bkp"&&
                   $row['Database']!= "logisys3_sdu_bkp"&&
                   $row['Database']!= "logisys3_sikkim_bkp"&&
                   $row['Database']!= "logisys3_sjvp_bkp"&&
                   $row['Database']!= "logisys3_ssa_bkp"&&
                   $row['Database']!= "logisys3_ssc_bkp"&&
                   $row['Database']!= "logisys3_stph_bkp"&&
				   $row['Database']!= "tmp"&&
				   $row['Database']!= "logisys3_vku_160123"&&
				   $row['Database']!= "logisys3_vku_bkp"&&
				   $row['Database']!= "rcub_pgcet_coun"&&
				   $row['Database']!= "resultsg_pgcet_coun"&&
				   $row['Database']!= "digival"&&
				   $row['Database']!= "ihf_test"&&
				   $row['Database']!= "logisys3_nub_bkp")
				$Databasename[] = $row['Database'];

	}

	foreach($Databasename as $key => $val)
	{
		

			@unlink('backup/'.$val.date("d-m-Y").'.gz');
			$backup_file = 'backup/'.$val. '_'.date("d-m-Y") . '.sql';
			$command='mysqldump --opt -h'.$dbhost.' -u'.$dbuser.' -p'.$dbpass.' '.$val.' > '.$backup_file.'';
			exec($command);

			if($backup_file)
			{
					$gzfile = 'backup/'.$val.date("d-m-Y").'.gz';
					$fp = gzopen ($gzfile, 'w9');
					gzwrite ($fp, file_get_contents($backup_file));
					gzclose($fp);
					unlink($backup_file);

					$file_path = 'backup/'.$val.date("d-m-Y").'.gz';
					
					if(file_exists($file_path))
					{
							$folder = date('d-m-Y');
							$s3 = S3Client::factory(
							array('credentials' => array(
									'key' => IAM_KEY,
									'secret' => IAM_SECRET
									),
									'version' => "latest",
									'region'  => 'ap-south-1'
							));
							
							try {
							
									$s3->putObject(['Bucket' => "logisys-bkps", 'Key' => date('d-m-Y')."/".$val.date("d-m-Y").'.gz', 'SourceFile' => $file_path]);
									unlink($file_path);
							}catch(S3Exception $e) {
									$arr['msg'] = 'Failed to upload';
									echo $arr;
									return;
							}
					}
			}
		
		
	}
   
   
?>