From 329fd4bcf6504c74e3906e51c6fc2124bc09cc02 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 30 Apr 2024 08:31:13 +0200 Subject: 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 --- cli/db-backup.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 cli/db-backup.php (limited to 'cli/db-backup.php') 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 +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); -- cgit v1.2.3