Skip to content

Commit

Permalink
doc: add update documentation
Browse files Browse the repository at this point in the history
Fixes #244
  • Loading branch information
fallen committed Sep 2, 2020
1 parent 26104c9 commit 8a2db44
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Demo: https://pytitiondemo.sionneau.net/

installation
configuration
update


Indices and tables
Expand Down
82 changes: 82 additions & 0 deletions doc/update.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
Update
******

Backup your files
=================

Backup your media files, those are the pictures uploaded by your users in the petition contents and metadata.

The files to backup are in the mediaroot directory that you configured in your settings in the `MEDIA_ROOT` variable.

.. code-block::
$ source path/to/pytition_venv/bin/activate
$ export DJANGO_SETTINGS_MODULE="pytition.settings.config" # path to your config
$ backup_dir=pytition_backup_$(date +%Y%m%d_%H%M%S)
$ mediaroot_dir=$(python3 pytition/manage.py shell -c 'from django.conf import settings; print(settings.MEDIA_ROOT)')
$ rsync -av $mediaroot_dir $backup_dir
Backup your Database
====================

For this, I would advise to use the tools provided with your database server.

* SQLite: just copy your .db file and you're done!
* PostgreSQL: use `pg_dump` to backup and `psql` to restore
* MariaDB / MySQL: use `mysqldump` to backup and `mysql` to restore

You can also try to backup using the django tool:

.. code-block::
$ source path/to/pytition_venv/bin/activate
$ export DJANGO_SETTINGS_MODULE="pytition.settings.config" # path to your config
$ # let's dump data
$ python3 pytition/manage.py dumpdata --all --output data.json
$ # now let's restore it
$ python3 pytition/manage.py loaddata data.json
.. warning::

Always *test* your backup mechanism. If not tested, you can only suppose your backups are worthless.
You need to try to restore them on a dummy and empty instance, in order to make sure the backup is OK.
Untested backups do not work.

Update to a newer Pytition version
==================================

You can simply run the `update` command of the `manage.py` CLI:

.. code-block::
$ source pytition_venv/bin/activate
$ python3 pytition/manage.py update
Or go through the following document and do it manually.

Download latest Pytition release tarball or update your git clone:

.. code-block::
$ git stash && git pull
$ version=$(curl -s https://api.github.com/repos/pytition/pytition/releases/latest | grep "tag_name" | cut -d : -f2,3 | tr -d \" | tr -d ,)
$ git checkout $version
Then upgrade Pytition's dependencies:

.. code-block::
$ source pytition_venv/bin/activate
(pytition_venv) $ pip3 install --upgrade -r requirements.txt
Then update your database scheme, update static files, compile new translation files:

.. code-block::
$ export DJANGO_SETTINGS_MODULE="pytition.settings.config" # path to your config
$ python3 pytition/manage.py migrate
$ python3 pytition/manage.py collectstatic
$ python3 pytition/manage.py compilemessages
Then restart your web server, be it apache or nginx, and also your application server (uWSGI).
Congratulations! You should now be OK with a brand new Pytition release!

0 comments on commit 8a2db44

Please sign in to comment.