Created
November 23, 2020 17:47
-
-
Save nithyadurai87/55fa4ed6a2866ddcf53cea1958bcf1ed 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 | |
def pushfile(): | |
push_cmd = 'rsync -arv -e "ssh -i /home/shrini/shrini-freepem.pem" /home/shrini/backups ubuntu@35.166.185.40:/home/ubuntu' | |
os.system(push_cmd) | |
def clr(): | |
clr_cmd = 'rm -f /home/shrini/backups/*' | |
os.system(clr_cmd) | |
dag = DAG('push_remote', description='Pushing files to remote every day', schedule_interval='20 00 * * *', start_date=datetime(2020, 11, 2), catchup=False) | |
pushfile_operator = PythonOperator(task_id='pushfile_task', python_callable=pushfile, dag=dag) | |
clear_operator = PythonOperator(task_id='clearing_task', python_callable=clr, dag=dag) | |
pushfile_operator >> clear_operator |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment