You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.1 KiB
36 lines
1.1 KiB
{% macro backup_to_object_store() %}
|
|
|
|
{%- call statement('backup', fetch_result=true, auto_begin=true) -%}
|
|
|
|
{% set backups =
|
|
{
|
|
"ADVENTUREWORKS":
|
|
["PUBLIC"]
|
|
}
|
|
%}
|
|
|
|
{% set day_of_month = run_started_at.strftime("%d") %}
|
|
|
|
{{ log('Backing up for Day ' ~ day_of_month, info = true) }}
|
|
|
|
{% for database, schemas in backups.items() %}
|
|
|
|
{% for schema in schemas %}
|
|
|
|
{{ log('Getting tables in schema ' ~ schema ~ '...', info = true) }}
|
|
|
|
{% set tables = dbt_utils.get_tables_by_prefix(schema.upper(), '', exclude='FIVETRAN_%', database=database) %}
|
|
|
|
{% for table in tables %}
|
|
{{ log('Backing up ' ~ table.name ~ '...', info = true) }}
|
|
{% set backup_table_command = get_backup_table_command(table, day_of_month) %}
|
|
{{ backup_table_command }}
|
|
{% endfor %}
|
|
|
|
{% endfor %}
|
|
|
|
{% endfor %}
|
|
|
|
{%- endcall -%}
|
|
|
|
{%- endmacro -%}
|