From bb221d26a31c68b8ebd9b6b5662d06229e7b3401 Mon Sep 17 00:00:00 2001 From: Pralav Singh Date: Wed, 2 Dec 2026 23:29:20 +0530 Subject: [PATCH 1/2] docs: correct MSColab database backup and restore commands --- docs/mscolab.rst | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/docs/mscolab.rst b/docs/mscolab.rst index cff153f10..4bcd9b604 100644 --- a/docs/mscolab.rst +++ b/docs/mscolab.rst @@ -217,11 +217,31 @@ directly to the server, e.g. :code:`http://127.0.0.1:8087`, and refuse the endpo Backup Data Base ................ -For backups you can dump by `pg_dump -d mscolab -f output.sql` the sqlite database -and restore it by `psql -v ON_ERROR_STOP=1 < new_db.sql` +Use the backup tools for the database configured by ``SQLALCHEMY_DATABASE_URI``. -On a PostgreSQL db you can regularly do backups by creating a dump -by `pg_dump `_ using a cron job :: +For SQLite, use the `sqlite3 command-line shell `_. +With the default database path, create a backup in the current directory with:: + + sqlite3 -readonly "$HOME/mss/colabdata/mscolab.db" ".backup 'mscolab-backup.db'" + +To restore the backup, stop MSColab and any other process using its database, then run the following command. +This replaces the current database contents:: + + sqlite3 "$HOME/mss/colabdata/mscolab.db" ".restore 'mscolab-backup.db'" + +Adjust the database file path in both commands if you use a custom location. + +For PostgreSQL, create a SQL dump with `pg_dump `_:: + + pg_dump -d mscolab -f output.sql + +Create an empty PostgreSQL database (named ``mscolab_restored`` in this example), then restore the same dump +with `psql `_:: + + psql -d mscolab_restored -v ON_ERROR_STOP=1 -f output.sql + +Use the database names and connection options for your PostgreSQL installation. +Regular PostgreSQL dumps can also be scheduled using a cron job:: #!/bin/bash timestamp=$(date +%Y%m%d_%H%M) From 8ef63e24237820825418b2c077eae7f859fee015 Mon Sep 17 00:00:00 2001 From: Pralav Singh Date: Thu, 3 Dec 2026 13:07:45 +0530 Subject: [PATCH 2/2] docs: guard SQLite restore and explain PostgreSQL recovery --- docs/mscolab.rst | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/docs/mscolab.rst b/docs/mscolab.rst index 4bcd9b604..cd68f26fe 100644 --- a/docs/mscolab.rst +++ b/docs/mscolab.rst @@ -220,16 +220,20 @@ Backup Data Base Use the backup tools for the database configured by ``SQLALCHEMY_DATABASE_URI``. For SQLite, use the `sqlite3 command-line shell `_. -With the default database path, create a backup in the current directory with:: +With the default database path, create a backup in your home directory with:: - sqlite3 -readonly "$HOME/mss/colabdata/mscolab.db" ".backup 'mscolab-backup.db'" + sqlite3 -readonly "$HOME/mss/colabdata/mscolab.db" ".backup '$HOME/mscolab-backup.db'" -To restore the backup, stop MSColab and any other process using its database, then run the following command. -This replaces the current database contents:: +To restore the backup, stop MSColab and any other process using its database, then run the following commands. +Only restore from an existing, non-empty backup file. This replaces the current database contents:: - sqlite3 "$HOME/mss/colabdata/mscolab.db" ".restore 'mscolab-backup.db'" + if [ -s "$HOME/mscolab-backup.db" ]; then + sqlite3 "$HOME/mss/colabdata/mscolab.db" ".restore '$HOME/mscolab-backup.db'" + else + echo "Backup file missing or empty; database was not restored." >&2 + fi -Adjust the database file path in both commands if you use a custom location. +Adjust the database and backup file paths in both examples if you use custom locations. For PostgreSQL, create a SQL dump with `pg_dump `_:: @@ -240,6 +244,8 @@ with `psql `_:: psql -d mscolab_restored -v ON_ERROR_STOP=1 -f output.sql +To use the restored database for recovery, stop MSColab, update ``SQLALCHEMY_DATABASE_URI`` in +``mscolab_settings.py`` to point to ``mscolab_restored``, and restart the server. Use the database names and connection options for your PostgreSQL installation. Regular PostgreSQL dumps can also be scheduled using a cron job::