Receive Mysql Database backup by email

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
AhmedBR
AppGini Super Hero
AppGini Super Hero
Posts: 327
Joined: 2013-09-19 10:23

Receive Mysql Database backup by email

Post by AhmedBR » 2016-04-22 22:27

I would like to share step by step to how to include this in your app:

Download this FREE script:
http://dwalker.co.uk/phpmysqlautobackup/
and add to your app folder

Configure your db and email details in run.php

at top of run.php add the following code to control access to the file using AppGini and to give the page same looks of your app:

Code: Select all

<?php
$currDir = dirname(__FILE__);
include("$currDir/defaultLang.php");
include("$currDir/language.php");
include("$currDir/lib.php");
include_once("$currDir/header.php");
?>
at the bottom of same page add this code:

Code: Select all

<?php
include_once("$currDir/footer.php");
?>

In Links-home.php (hooks folder) add the following lines to create a button in your app:

Code: Select all

 $homeLinks[] = array(
'url' => 'your app folder/run.php',
'title' => 'BackUp DataBase',
'description' => 'BackUp by email',
'groups' => array('2'),
'grid_column_classes' => '',
'panel_classes' => '',
'link_classes' => 'btn btn-danger',
'icon' => 'icon path'
);

Anytime you need to make a back up just click the button, that is it.

you can also use CRON job to automate the backup or from the same link above download phpJobScheduler which is a replacement for cron

have a nice backup :D
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper

AhmedBR
AppGini Super Hero
AppGini Super Hero
Posts: 327
Joined: 2013-09-19 10:23

Re: Receive Mysql Database backup by email

Post by AhmedBR » 2016-04-22 23:51

You can also restrict the direct access link using the following code (given as an example by Ahmad in another topic :D )

Code: Select all

	/* grant access to the groups 'Admins' and 'Data entry' */
	$mi = getMemberInfo();
	if(!in_array($mi['group'], array('Admins', 'Data entry'))){
		echo "Access denied";
		exit;
	}
In This case the full code at topo of run.php should look like this:

Code: Select all

<?php

$currDir = dirname(__FILE__);
include("$currDir/defaultLang.php");
include("$currDir/language.php");
include("$currDir/lib.php");
include_once("$currDir/header.php");

	/* grant access to the groups 'Admins' and 'Data entry' */
	$mi = getMemberInfo();
	if(!in_array($mi['group'], array('Admins', 'Data entry'))){
		echo "   Access denied";
		exit;
	}
	
?>
Adjust as needed, so far working very well. :D

=========================
Using AppGini 5.5 385
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper

AhmedBR
AppGini Super Hero
AppGini Super Hero
Posts: 327
Joined: 2013-09-19 10:23

Re: Receive Mysql Database backup by email

Post by AhmedBR » 2016-04-23 13:53

There is another free script for database backup that I find it very cool:
backup-database.jpg
backup-database.jpg (44.13 KiB) Viewed 3211 times
Download Here:
http://www.netartmedia.net/dbbackup
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper

Post Reply