#!/bin/bash source lib/lib.sh ENVS=(PROJECT_NAME DBTYPE DBHOST DBUSER DBPASS DBTABLE STORAGE_TYPE STORAGE_HOST STORAGE_PATH ACCOUNT_ID APPLICATION_KEY) for ENV in "${ENVS[@]}"; do if [[ -z "${!ENV+x}" ]]; then log_error "Not set $ENV env" exit 1 fi done case $DBTYPE in mysql) log "DB type is " source lib/mysql.sh ;; postgresql|psql|postgres) log "DB type is " source lib/postgresql.sh ;; mongo|mongod|mongodb) log "DB type is " source lib/mongo.sh ;; *) log_error "Unknown DB type, known , " exit 1 ;; esac case $STORAGE_TYPE in b2) log "Storage type is " source storage/b2.sh ;; s3) log "Storage type is " source storage/s3.sh ;; *) log_error "Unknown storage, known , " exit 1 ;; esac ARCHIVE="/srv/backup/""$PROJECT_NAME"_`date +%Y-%m-%d-%H-%M`".dump" log "Backuping.." db_backup log "Copy to ${STORAGE}" storage_upload log "Completed" exit 0