Skip to content

Instantly share code, notes, and snippets.

@nithyadurai87
Last active November 23, 2020 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nithyadurai87/8104b9c364f9bd7c6a7b5aeafee24a79 to your computer and use it in GitHub Desktop.
Save nithyadurai87/8104b9c364f9bd7c6a7b5aeafee24a79 to your computer and use it in GitHub Desktop.
from datetime import datetime
from airflow import DAG
import os
from airflow.operators.python_operator import PythonOperator
from airflow.models import Variable
def backup():
backup_cmd = 'mysqldump -u root -ppassword sample > "/home/shrini/backups/"sample_"$(date +"%Y%m%d_%H%M%S").sql"'
os.system(backup_cmd)
dag = DAG('mysql_backup', description='Mysql backup every hour', schedule_interval='00 * * * *', start_date=datetime(2020, 11, 2), catchup=False)
backup_operator = PythonOperator(task_id='backup_task', python_callable=backup, dag=dag)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment