diff options
| author | 2024-04-30 08:31:13 +0200 | |
|---|---|---|
| committer | 2024-04-30 08:31:13 +0200 | |
| commit | 329fd4bcf6504c74e3906e51c6fc2124bc09cc02 (patch) | |
| tree | 11c6c56d404403eca1996e89aeb6a978b9d92237 /cli/db-backup.php | |
| parent | 173555795adf6614dff33893b373f22542910675 (diff) | |
CLI database backup and restore (#6387)
* CLI database backup and restore
Can also be used to migrate from one database to another (e.g. MySQL to PostgreSQL) or to ease upgrade to a major PostgreSQL version (e.g. 15 to 16).
* +x
* Fix some cases
* Update to docker-compose-v2
* More documentation
Diffstat (limited to 'cli/db-backup.php')
| -rwxr-xr-x | cli/db-backup.php | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/cli/db-backup.php b/cli/db-backup.php new file mode 100755 index 000000000..290b5cc7b --- /dev/null +++ b/cli/db-backup.php @@ -0,0 +1,20 @@ +#!/usr/bin/env php +<?php +declare(strict_types=1); +require(__DIR__ . '/_cli.php'); + +performRequirementCheck(FreshRSS_Context::systemConf()->db['type'] ?? ''); +$ok = true; + +foreach (listUsers() as $username) { + $username = cliInitUser($username); + $filename = DATA_PATH . '/users/' . $username . '/backup.sqlite'; + @unlink($filename); + + echo 'FreshRSS backup database to SQLite for user “', $username, "”…\n"; + + $databaseDAO = FreshRSS_Factory::createDatabaseDAO($username); + $ok &= $databaseDAO->dbCopy($filename, FreshRSS_DatabaseDAO::SQLITE_EXPORT); +} + +done((bool)$ok); |
