MMOframework
Pourquoi l'IA Playground Bibliothèques Développeurs Agence
FR EN
Créer un projet en direct
Index

iBackupRepository

MMO\core\interfaces · 1 symbole · générée le 30 Nov 2026

interface

iBackupRepository

iBackupRepository.php:24

A repository that can dump its database into a file, and put one back: what mmo.admin's backup, restore, migrate's snapshot and data-pull/data-push go through, whatever the database is -- MongoDB (mmo.mongodb's MongoRepository), MySQL or SQLite (mmo.pdo's PDORepository), a folder of JSON collections (JsonRepository).

interface MMO\core\interfaces\iBackupRepository
Espace de noms
MMO\core\interfaces
**Through a shell.** Both run through an [`iShell`](https://mmoframework.fr/documentation/mmo.core/php/interfaces/iShell.md#ishell): this machine's by default, a server's (`SSH`) to dump or restore the database of that server. A remote dump is written on the server ($remoteFile), then downloaded; a restore of a local file uploads it first. **What `$database` is.** For a database server, its name (`acme`), on the shell's machine. For a database of files ([`getBackupFiles`](https://mmoframework.fr/documentation/mmo.core/php/interfaces/iBackupRepository.md#ibackuprepository-getbackupfiles) not empty), the application's root folder on the shell's machine: its files are found there as they are here under `{root}` -- [`getBackupDatabase`](https://mmoframework.fr/documentation/mmo.core/php/interfaces/iBackupRepository.md#ibackuprepository-getbackupdatabase) says what it is for this repository's own data.
$file = $repository->backup(); // this machine's database, into getBackupFolder() $repository->restore($file, null, ['users']); // only the users, back $dump = $repository->backup(null, $repository->getBackupDatabase('/var/www/acme/current'), $ssh, '/var/www/acme/backups/x');

Méthodes6

backup($filename, $database, $shell, $remoteFile)

abstractiBackupRepository.php:57

Dump a database into a file of this machine.

abstract function backup( ?string $filename = null, ?string $database = null, ?MMO\core\interfaces\iShell $shell = null, ?string $remoteFile = null ): string
$filename = nullnull | stringthe dump (null: getBackupName, in getBackupFolder; relative: in it)
$database = nullnull | stringiBackupRepository (null: this repository's)
$shell = nullnull | iShellwhere the database is (null: this machine)
$remoteFile = nullnull | stringa remote shell: where the dump is written there before it is downloaded (null: a temporary file, removed)
retournestringthe dump, here

getBackupDatabase($root)

abstractiBackupRepository.php:40
abstract function getBackupDatabase(?string $root = null): string
$root = nullnull | stringthe application's root on another machine (null: this one's)
retournestringwhat backup and restore take as $database for this repository's own data there: its name for a database server, that root for a database of files

getBackupFiles()

abstractiBackupRepository.php:46
abstract function getBackupFiles(): array
retournearraystring> a database of files: collection => its file here, absolute; [] for a database server

getBackupFolder()

abstractiBackupRepository.php:26
abstract function getBackupFolder(): string
retournestringwhere this machine keeps the dumps, absolute

getBackupName($date, $database)

abstractiBackupRepository.php:33
abstract function getBackupName(DateTimeInterface|int|null $date = null, ?string $database = null): string
$date = nullDateTimeInterface | int | nullwhen (null: now)
$database = nullnull | stringthe database (null: this repository's)
retournestringthe file name of a dump, its extension telling which repository reads it

restore($filename, $database, $collections, $shell, $oldDatabase, $drop)

abstractiBackupRepository.php:68

Replace a database with a dump.

abstract function restore( DateTimeInterface|string|int $filename, ?string $database = null, ?array $collections = null, ?MMO\core\interfaces\iShell $shell = null, ?string $oldDatabase = null, bool $drop = true ): void
$filenameDateTimeInterface | string | intthe dump, here or on the shell's machine (a date: getBackupName)
$database = nullnull | stringiBackupRepository (null: this repository's)
$collections = nullnull | arrayonly these (null: all of the dump)
$shell = nullnull | iShellwhere the database is (null: this machine)
$oldDatabase = nullnull | stringthe database the dump was made of, when it is restored under another name
$drop = trueboolremove first what the dump does not hold (false: keep it)
retournevoid