Added new console command for created data backups.

This commit is contained in:
Alex Tselegidis 2020-12-04 14:28:18 +02:00
parent 8c8160897a
commit 3f43d2f768
4 changed files with 50 additions and 0 deletions

3
.gitignore vendored
View File

@ -12,6 +12,9 @@
/assets/js/**/*.min.js
/assets/css/**/*.min.css
/config.php
/storage/backups/*
!/storage/backups/.htaccess
!/storage/backups/index.html
/storage/cache/*
!/storage/cache/.htaccess
!/storage/cache/index.html

View File

@ -31,6 +31,8 @@ class Console extends EA_Controller {
parent::__construct();
$this->load->helper('file');
$this->load->dbutil();
$this->load->library('migration');
$this->load->model('admins_model');
$this->load->model('customers_model');
@ -156,6 +158,40 @@ class Console extends EA_Controller {
$this->output->set_output(PHP_EOL . '⇾ Installation completed, login with "administrator" / "administrator".' . PHP_EOL . PHP_EOL);
}
/**
* Create a backup file.
*
* Use this method to backup your Easy!Appointments data.
*
* Usage:
*
* php index.php console backup
*
* php index.php console backup /path/to/backup/folder
*
* @throws Exception
*/
public function backup()
{
$path = isset($GLOBALS['argv'][3]) ? $GLOBALS['argv'][3] : APPPATH . '/../storage/backups';
if ( ! file_exists($path))
{
throw new Exception('The backup path does not exist™: ' . $path);
}
if ( ! is_writable($path))
{
throw new Exception('The backup path is not writable: ' . $path);
}
$contents = $this->dbutil->backup();
$filename = 'easyappointments-backup-' . date('Y-m-d-His') . '.gz';
write_file(rtrim($path, '/') . '/' . $filename, $contents);
}
/**
* Trigger the synchronization of all provider calendars with Google Calendar.
*

1
storage/backups/.htaccess Executable file
View File

@ -0,0 +1 @@
deny from all

10
storage/backups/index.html Executable file
View File

@ -0,0 +1,10 @@
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>