diff options
Diffstat (limited to 'cli/export-sqlite-for-user.php')
| -rwxr-xr-x | cli/export-sqlite-for-user.php | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/cli/export-sqlite-for-user.php b/cli/export-sqlite-for-user.php new file mode 100755 index 000000000..027d13f38 --- /dev/null +++ b/cli/export-sqlite-for-user.php @@ -0,0 +1,28 @@ +#!/usr/bin/php +<?php +require(__DIR__ . '/_cli.php'); + +$params = [ + 'user:', + 'filename:', +]; + +$options = getopt('', $params); + +if (!validateOptions($argv, $params) || empty($options['user']) || empty($options['filename'])) { + fail('Usage: ' . basename(__FILE__) . ' --user username --filename /path/to/db.sqlite'); +} + +$username = cliInitUser($options['user']); +$filename = $options['filename']; + +if (pathinfo($filename, PATHINFO_EXTENSION) !== 'sqlite') { + fail('Only *.sqlite files are supported!'); +} + +echo 'FreshRSS exporting database to SQLite for user “', $username, "”…\n"; + +$databaseDAO = FreshRSS_Factory::createDatabaseDAO($username); +$ok = $databaseDAO->dbCopy($filename, FreshRSS_DatabaseDAO::SQLITE_EXPORT); + +done($ok); |
