django-dbbackup
django-dbbackup copied to clipboard
Add celery config to the docs
Feature Request
Please help us help you by filling out any applicable information in this template and removing the rest!
Is your feature request related to a problem?
Request to add some info to the docs
Describe the solution you'd like
A section for django-celery-beat periodic tasks
Additional context
Since the docs mention that additional integration examples would be welcome, and I don't know how to make a proper PR:
django-celery-beat
myapp/management/my_custom_command.py (can be called on app startup)
from django.core.management.base import BaseCommand, CommandError
from django_celery_beat.models import CrontabSchedule, PeriodicTask
import pytz
class Command(BaseCommand):
help = 'Creates crontab schedule objects and periodic tasks that use them'
def handle(self, *args, **options):
every_day, _ = CrontabSchedule.objects.get_or_create(
minute='0',
hour='0',
day_of_week='*',
day_of_month='*',
month_of_year='*',
timezone=pytz.timezone('UTC')
)
PeriodicTask.objects.get_or_create(
crontab=every_day,
name='Backup DB',
task='myapp.tasks.backup_db',
)
PeriodicTask.objects.get_or_create(
crontab=every_day,
name='Backup Media',
task='myapp.tasks.backup_media',
)
tasks.py
from celery import Celery
from django.core import management
app = Celery()
@app.task
def backup_db():
management.call_command('dbbackup')
@app.task
def backup_media():
management.call_command('mediabackup')
PR link
If you have opened a pull request to address the issue, please link it here.