#!/usr/bin/env bash

set -euo pipefail

printf "Database size: $(./get_database_size.sh)\n"

bucket="zoox-terraform-hwsd-run"
file_name="hwsd_backup_$(date +%Y%m%dT%H%M%S)"
path="backup/${file_name}"
full_path="s3://${bucket}/${path}"

printf "Backup path: ${full_path}\n"
./dump_production.sh | aws s3 cp - "${full_path}"

printf "Use 'aws s3 cp ${full_path} <local path>' to download locally.\n"
printf "NOTE: File format is .tgz\n"
