How to bypass "yes" on Django crontab in the function

I have a Django application with dbbackup library and crontab library that will take the database backup every one hour.

https://django-dbbackup.readthedocs.io/en/master/index.html https://pypi.org/project/django-crontab/

In order to restore the back up file. I have to use this command in the shell manually.

python manage.py dbrestore

However, I want to schedule this task by using crontab.

Here is my code. `

from django.core.management import call_command

def restore_scheduled_job():
    try:
        call_command('dbrestore')
    except:
        pass

`

This will not work since after the "python manage.py dbrestore" command, I have type "y" in order to process the command.

How can I bypass this yes in the function?

I researched in the documentation but I couldn't find any solutions.

Back to Top