mirror of
https://github.com/demostf/backup.git
synced 2026-06-03 22:14:08 +02:00
initial backup script
This commit is contained in:
commit
d5896cc6f3
6 changed files with 147 additions and 0 deletions
27
backup.php
Normal file
27
backup.php
Normal 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);
|
||||
Loading…
Add table
Add a link
Reference in a new issue