"""
A maintenance workflow that you can deploy into Airflow to periodically take
backups of various Airflow configurations and files.

airflow trigger_dag airflow-backup-configs

"""
from airflow.models import DAG, Variable
from airflow.operators.python_operator import PythonOperator
from airflow.configuration import conf
from datetime import datetime, timedelta
import os
import airflow
import logging
import subprocess
# airflow-backup-configs
DAG_ID = os.path.basename(__file__).replace(".pyc", "").replace(".py", "")
# How often to Run. @daily - Once a day at Midnight
START_DATE = airflow.utils.dates.days_ago(1)
# Who is listed as the owner of this DAG in the Airflow Web Server
SCHEDULE_INTERVAL = "@daily"
# List of email address to send email alerts to if this job fails
DAG_OWNER_NAME = "operations"
ALERT_EMAIL_ADDRESSES = []
# Format options: https://www.tutorialspoint.com/python/time_strftime.htm
BACKUP_FOLDER_DATE_FORMAT = "%Y%m%d%H%M%S"
BACKUP_HOME_DIRECTORY = Variable.get("airflow_backup_config__backup_home_directory", "/tmp/airflow_backups")