diff --git a/docs/mscolab.rst b/docs/mscolab.rst index cff153f10..cd68f26fe 100644 --- a/docs/mscolab.rst +++ b/docs/mscolab.rst @@ -217,11 +217,37 @@ 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 your home directory with:: + + 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 commands. +Only restore from an existing, non-empty backup file. This replaces the current database contents:: + + 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 and backup file paths in both examples if you use custom locations. + +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 + +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:: #!/bin/bash timestamp=$(date +%Y%m%d_%H%M)