<commit_before>Fabric commands
===============

TracPro uses the `Caktus project template
<https://github.com/caktus/django-project-template>`_. See the :doc:`server documentation</servers/server-setup>` to learn more about server architecture and
provisioning.

Before using fabric commands, follow all of the steps in the
:doc:`developer setup docs </developers/local-developer-setup>` to ensure that you have all of the
required credentials.

You can get a full list of Fabric commands by running ``fab --list``, or read
through the source at `fabfile.py <https://github.com/rapidpro/tracpro/blob/develop/fabfile.py>`_.

Copying data for local development
----------------------------------

To copy the database and media files from a remote server to your local
development environment::

    fab [production|staging] mirror_to_dev

**NOTE:** Migrations must be run (``django-admin migrate``) if the local
branch has migrations that have not yet been run on the remote server.

Copying production data to staging
----------------------------------

To copy the production database to staging::

    fab prod_db_to_staging

**NOTES:** Migrations must run (``fab staging manage_run:"migrate"``) if the
branch that is deployed on staging has new migrations that have not been run
on production.

Running commands on the server
------------------------------

To run a management command on a remote server::

    fab [production|staging] manage_run:"command_name -arg --option param1 param2"

Use the ``manage_shell`` alias to run a Python shell on a remote server::

    fab [production|staging] manage_shell
<commit_msg>Adjusting fabric command in documentation to correct command<commit_after>Fabric commands
===============

TracPro uses the `Caktus project template
<https://github.com/caktus/django-project-template>`_. See the :doc:`server documentation</servers/server-setup>` to learn more about server architecture and
provisioning.

Before using fabric commands, follow all of the steps in the
:doc:`developer setup docs </developers/local-developer-setup>` to ensure that you have all of the
required credentials.

You can get a full list of Fabric commands by running ``fab --list``, or read
through the source at `fabfile.py <https://github.com/rapidpro/tracpro/blob/develop/fabfile.py>`_.

Copying data for local development
----------------------------------

To copy the database and media files from a remote server to your local
development environment::

    fab [production|staging] reset_local_db

**NOTE:** Migrations must be run (``django-admin migrate``) if the local
branch has migrations that have not yet been run on the remote server.

Copying production data to staging
----------------------------------

To copy the production database to staging::

    fab prod_db_to_staging

**NOTES:** Migrations must run (``fab staging manage_run:"migrate"``) if the
branch that is deployed on staging has new migrations that have not been run
on production.

Running commands on the server
------------------------------

To run a management command on a remote server::

    fab [production|staging] manage_run:"command_name -arg --option param1 param2"

Use the ``manage_shell`` alias to run a Python shell on a remote server::

    fab [production|staging] manage_shell

{'fraction_non_alphanumeric': 0.13895631067961164, 'fraction_numerical': 0.0012135922330097086, 'mean_word_length': 3.5288461538461537, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2243759', 'n_tokens_mistral': 863, 'n_tokens_neox': 828, 'n_words': 387}