Skip to content

Instantly share code, notes, and snippets.

@nithyadurai87
Created November 23, 2020 17:47
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/55fa4ed6a2866ddcf53cea1958bcf1ed to your computer and use it in GitHub Desktop.
Save nithyadurai87/55fa4ed6a2866ddcf53cea1958bcf1ed 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
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