initial backup script

This commit is contained in:
Robin Appelman 2017-06-10 13:48:42 +02:00
commit d5896cc6f3
6 changed files with 147 additions and 0 deletions

27
backup.php Normal file
View file

@ -0,0 +1,27 @@
<?php declare(strict_types=1);
require 'vendor/autoload.php';
if (!getenv('STORAGE_ROOT')) {
$env = new \Dotenv\Dotenv(__DIR__);
$env->load();
}
$store = new \Demostf\Backup\Store(getenv('STORAGE_ROOT'));
$source = new \Demostf\Backup\Source(getenv('SOURCE'));
$statePath = getenv('STATE_FILE');
if (file_exists($statePath)) {
$lastPage = intval(file_get_contents($statePath));
if (!$lastPage) {
$lastPage = 1;
}
} else {
$lastPage = 1;
}
$backup = new \Demostf\Backup\Backup($source, $store);
$currentPage = $backup->backupFrom($lastPage);
file_put_contents($statePath, $currentPage);