Giter VIP home page Giter VIP logo

mysql_backup_restore_php's Introduction

mysql_backup_restore_php

Mysql database backup/restore system in PHP

  • Requires (PHP 5 >= 5.2.0, PHP 7, PECL zip >= 1.8.0) for ZipArchive
  • Requires (PHP 5, PHP 7) for The mysqli class
  • Requires Mysql Version>=50549
  • Requires sufficient Mysql user permissions to :
  •  				- enumerate databases(not necessary) 
    
  •  				- create/delete tables(not necessary)
    
  •  				- write data(to restore database)
    
  •  				- read data(main purpose)
    
  • Requires jquery>=1.11.1 for Client side
  • Tested in all major browsers
  • Tested environment :
  •  		- Server : Apache/2.4.7 (Ubuntu)
    
  •          - System : PHP/5.5.9-1ubuntu4.17
    
  •          - Mysql  : 50549 (Version)
    
  • Usage :
  •  provide Mysql HOST,USERNAME & PASSWORD
    
  • MIT License

mysql_backup_restore_php's People

Contributors

joshyfrancis avatar

Stargazers

 avatar

Watchers

 avatar

mysql_backup_restore_php's Issues

Database list not showing

Hello,
I am using your script but it is not showing databases list, neither in mamp nor on live server. What can be the issue. Please reply.

It sucks!!

actually it is not working on my site and tried in local too and tried in two of my other sites.
Don't know what is the issue is>>>>

HELP ME PLEASE

NEED A SCRIPT THAT MAKE AUTO EXPORT IN .CSV FILE JUST ONE TABLE OF MY DATABASE

BUT I CANT MAKE

LOOK THIS EXAMPLE
`<?php
/*

////////////////////////////////////////////////////////////////////////////
function aedbttf_add_custom_cron_schedule($schedules) {

//Every 15 minutes
$schedules['every15minutes'] = array(
	'interval' => 900,
	'display' => __('Every 15 minutes')
);

//Every 30 minutes
$schedules['every30minutes'] = array(
	'interval' => 1800,
	'display' => __('Every 30 minutes')
);

return $schedules;

}
add_filter('cron_schedules', 'aedbttf_add_custom_cron_schedule');

////////////////////////////////////////////////////////////////////////////
function aedbttf_activation_hook() {
wp_clear_scheduled_hook( 'aedbttf_db_table_auto_export_cron_hook' );
if ( ! wp_next_scheduled( 'aedbttf_db_table_auto_export_cron_hook' ) ) {
wp_schedule_event( time(), 'hourly', 'aedbttf_db_table_auto_export_cron_hook' ); //Use 'hourly' or custom interval defined in aedbttf_add_custom_cron_schedule above. Plugin needs to be de-activated and re-activated for schedule to be changed
}
}
register_activation_hook( FILE , 'aedbttf_activation_hook' );
add_action( 'aedbttf_db_table_auto_export_cron_hook', 'aedbttf_do_db_table_export' );

////////////////////////////////////////////////////////////////////////////
function aedbttf_deactivation_hook() {
wp_clear_scheduled_hook( 'aedbttf_db_table_auto_export_cron_hook' );
}
register_deactivation_hook( FILE , 'aedbttf_deactivation_hook' );

////////////////////////////////////////////////////////////////////////////
function aedbttf_do_db_table_export() {

///////////////////////////////////////////////////////////////////////////
//MAKE CHANGES HERE

$filename = "my-db-table.csv"; //Just the filename you want to use WITHOUT the path. Include .csv extension

$columns = "column2,column3,column4"; //Comma seperated list of columns to retrieve from DB in MySQL query

$table_name = "mytablename"; //Just the DB table name by itself WITHOUT the prefix

$where = "WHERE somecolumn='sometext'"; //MySQL WHERE options or set to "" for none. Example:   WHERE somecolumn='sometext'

$order_by = "ORDER BY anothercolumn DESC"; //MySQL ORDER BY options or set to "" for none. Example:   ORDER BY anothercolumn DESC

$limit = "LIMIT 250"; //MySQL LIMIT options or set to "" for none. Example:   LIMIT 250

$header_row = $columns; //Comma seperated list to use as header row in CSV file. Set to "" for no header row. Default is set to = $columns;

//DO NOT CHANGE ANYTHING BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING
///////////////////////////////////////////////////////////////////////////

global $wpdb;

$table_name = $wpdb->prefix.$table_name; //Add prefix to table name

$query = "SELECT {$columns} FROM `{$table_name}` {$where} {$order_by} {$limit}"; //Create MySQL query string

$results = $wpdb->get_results($query, ARRAY_A); //Do MySQL databse query

if ($header_row != "") {
	$output = $header_row; //Set header row for CSV file
} else {
	$output = ""; //No header row in CSV file
}

foreach ($results as $row) {
	$output = $output."\r\n";
	
	$columns_array = split(",",$columns);

	$first_column = true;
	foreach ($columns_array as $column) {
		if ($first_column != true) {
			$output = $output.",";

		} else {
			$first_column = false;

		}

		$output = $output.$row[$column];

	}
}

//WARNING: Files written to plugin_dir_path are PUBLICLY accessible in the /wp-content/plugins/auto-export-db-table-to-file/ directory.
$filename = plugin_dir_path( __FILE__ ).$filename; //Add path to plugin directory

$file_handle = fopen($filename, 'w'); //Open file for write

fwrite($file_handle, $output); //Write output to file

fclose($file_handle); //Close file

}

?>`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.