Closed rivernews closed 5 years ago
For future reference:
.json
yet, create one by dumping the previous database: ./manage.py dumpdata > backup.json
.python manage.py flush
python manage.py migrate
no need, only for brand new database)echo "delete from auth_permission; delete from django_content_type;" | python manage.py dbshell
python manage.py loaddata the-dumped-db-backup.json
Some useful K8 commands for debugging cron jobs
# Example: get the pods running the job `db-backup-cronjob-1566709740`
. ./my-kubectl.sh get pods --selector=job-name=db-backup-cronjob-1566709740 -n cicd-django
. ./my-kubectl.sh get jobs
# You can also grep to get cron job pods
. ./my-kubectl.sh get pods --all-namespaces | grep cron
# Or try combo to get the pod
job_name="$(. ./my-kubectl.sh get jobs | grep --max-count 1 cronjob | awk '{print $1;}')"
echo "job name is ${job_name}"
. ./my-kubectl.sh get pods --all-namespaces --selector=job-name=${job_name}
# pods=$(. ./my-kubectl.sh get pods --selector=job-name=${job_name} --output=jsonpath={.items[].metadata.name})
# Get the log
. ./my-kubectl.sh logs $pods
# Directly by the name
. ./my-kubectl.sh get jobs
. ./my-kubectl.sh logs jobs/<the job name you see>
Seems like the K8 cron job is not working, because doesn't receive admin email.