Add an opt-in CLI that exports each user's database to `data/users/<user>/sqlite-backups/<YYYYMMDDTHHMMSSZ>.sqlite` (UTC) and prunes older files to a configured count. Gated by two new settings, `auto_sqlite_export.enabled` and `auto_sqlite_export.retention`. Kept separate from `cli/db-backup.php` / `cli/db-restore.php`, which stay the fixed-filename migration tool. First step of #8183. Co-authored-by: Bjørn A. Andersen <polybjorn@users.noreply.github.com>
4.3 KiB
Backup
What to back up
./data/- required. You can skipcache/andfavicons/; FreshRSS rebuilds them../extensions/- recommended if you use third-party extensions../i/themes/- optional, only if you have added custom themes.- External database (MySQL, MariaDB, PostgreSQL) - back up separately with
./cli/db-backup.php(portable SQLite per user) ormysqldump/pg_dump. SQLite is covered by./data/above.
All other folders belong to the source code and are restored by a fresh install or upgrade.
Full installation backup
Do this before an upgrade.
The following commands assume your FreshRSS directory is /usr/share/FreshRSS; substitute your path if installed elsewhere.
ℹ️ It is safer to stop your web server and cron during maintenance operations.
Creating a database backup
Back up each user's database to ./data/users/*/backup.sqlite:
cd /usr/share/FreshRSS/
./cli/db-backup.php
Creating a backup of all files
Save the backup to your home directory:
cd ~
Create a gzipped tar archive of the FreshRSS directory:
tar -czf FreshRSS-backup.tgz -C /usr/share/FreshRSS/ .
Restoring files from a backup
Extract the backup into your FreshRSS directory:
tar -xzf ~/FreshRSS-backup.tgz -C /usr/share/FreshRSS/
Restoring a database backup
Restore each user's database from ./data/users/*/backup.sqlite:
cd /usr/share/FreshRSS/
./cli/db-restore.php --delete-backup --force-overwrite
Automatic periodic SQLite export
For ongoing on-server backups, separate from the one-shot db-backup.php / db-restore.php migration workflow, enable automatic SQLite export in ./data/config.php:
'auto_sqlite_export' => [
'enabled' => true,
'retention' => 7,
],
Then schedule it (for example via cron):
./cli/export-sqlite-auto.php
Each run writes ./data/users/<username>/sqlite-backups/<YYYYMMDDTHHMMSSZ>.sqlite (UTC) for every user and prunes older files to the configured retention count.
Migrating the database
First, back up all user databases to SQLite files:
cd /usr/share/FreshRSS/
./cli/db-backup.php
Change your database setup:
- to change the database type (e.g. from MySQL to PostgreSQL), edit
./data/config.phpaccordingly. - to upgrade to a major PostgreSQL version, after a PostgreSQL backup, delete the old instance and start a new one (remove the PostgreSQL volume if using Docker).
Restore all user databases from the SQLite files:
cd /usr/share/FreshRSS/
./cli/db-restore.php --delete-backup --force-overwrite
See also our Docker documentation for migrating the database.
Backing up selected content
Feed list export
You can export your feed list in OPML format either from the web interface, or from the command-line interface.
The OPML export only includes the standard OPML parameters; it omits FreshRSS-specific attributes like refresh frequency, credentials, user agent, and XPath web scraping rules.
For a full export including these, use the SQLite export described below.
Exporting your data
MySQL or MariaDB
You can use phpMyAdmin or mysqldump. Replace <db_user> with your database username, <db_host> with your database server hostname, and <freshrss_db> with the FreshRSS database name:
mysqldump --skip-comments --disable-keys --user=<db_user> --password --host <db_host> --result-file=freshrss.dump.sql --databases <freshrss_db>
Any database
Export your database to a SQLite file with the command-line interface:
./cli/export-sqlite-for-user.php --user <username> --filename </path/to/db.sqlite>
Import the SQLite file back into your database:
./cli/import-sqlite-for-user.php --user <username> --filename </path/to/db.sqlite>
ℹ️ The database filename must use the
.sqliteextension for both commands to work.
The export/import flow is useful when you need to:
- fully export a user,
- back up your service,
- migrate the service to another server,
- change the database type,
- fix database corruption.