# How to add a Python script for install/update/restore

**URL:** <https://forum.yunohost.org/t/how-to-add-a-python-script-for-install-update-restore/30924>\
**Category:** Apps packaging\
**Tags:** english\
**Created:** [August 28, 2024, 8:43am UTC](https://forum.yunohost.org/t/how-to-add-a-python-script-for-install-update-restore/30924 "2024-08-28T08:43:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jedie](https://forum.yunohost.org/letter_avatar_proxy/v4/letter/j/b5a626/32.png) [@jedie](https://forum.yunohost.org/u/jedie)\
**Post date:** [August 28, 2024, 8:43am UTC](https://forum.yunohost.org/t/how-to-add-a-python-script-for-install-update-restore/30924/1 "2024-08-28T08:43:43Z")

</div>

We have currently this: [Writing app scripts | Yunohost Documentation](https://yunohost.org/en/packaging_scripts)

```auto
scripts/
   - _common.sh # Some "common" definition, typically custom helpers or global variables used accross all scripts
   - install # The install procedure
   - remove # The remove procedure
   - upgrade # The upgrade procedure
   - backup # The backup procedure - in fact it only "declares" what should be backup / no actual real backup happens at this point except dumping SQL databases
   - restore # The restore procedure
   - change_url # Some apps do also provide a change url script, which corresponds to changing the URL endpoint of the app, which may be as simple as changing the nginx conf, or may involve significant changes in the app DB

```

I would like to add a python script into the `scripts` folder and use it in install/update/restore… (I would like to replace the “install python” script parts from `_common.sh`, see also: [Use newer Python than 3.9 ?!?](https://forum.yunohost.org/t/use-newer-python-than-3-9/22568) )

It works in principle: [Install Python with a python script ;) by jedie · Pull Request #72 · YunoHost-Apps/django-for-runners\_ynh · GitHub](https://github.com/YunoHost-Apps/django-for-runners_ynh/pull/72)

But the restore fails, because my script `install_python.py` is not in the backup, see: [YunoRunner for CI](https://ci-apps-bookworm-dev.yunohost.org/ci/job/2295) line 13002-13027

---

<div class="post-metadata">

**Author:** ![jedie](https://forum.yunohost.org/letter_avatar_proxy/v4/letter/j/b5a626/32.png) [@jedie](https://forum.yunohost.org/u/jedie)\
**Post date:** [August 28, 2024, 2:39pm UTC](https://forum.yunohost.org/t/how-to-add-a-python-script-for-install-update-restore/30924/2 "2024-08-28T14:39:10Z")

</div>

Think i found a solution:  
Store the file into: `conf/install_python.py` and add `cp ../conf/install_python.py "$data_dir/install_python.py"` in `install` and `upgrade` scripts.

This is also great, because it’s callable in the shell from the data directory, too 😉
