Last active
November 23, 2020 17:43
-
-
Save nithyadurai87/8104b9c364f9bd7c6a7b5aeafee24a79 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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