#!/usr/bin/env bash

backup-dotenv-files() {
    if [[ -z "$1" ]]; then
        echo "\$1/path is empty."
        return 1
    fi

    local task_config_dir
    task_config_dir=${TASK_DOTENV_DIR:-$HOME/.config/taskfile.build}
    local backup_filepath
    backup_filepath="$1/$(date +'%Y-%m-%d')-backup-dotenv-files.tar.gz"

    echo "Backing up env files to: $backup_filepath"
    cd "$task_config_dir" || return 1
    tar -czf "$backup_filepath" .env.* ./*.env 2>/dev/null
}
bdf() {
    backup-dotenv-files "$@"
}
