59 lines
1.1 KiB
Bash
Executable File
59 lines
1.1 KiB
Bash
Executable File
#!/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 <mysql>"
|
|
source lib/mysql.sh
|
|
;;
|
|
postgresql|psql|postgres)
|
|
log "DB type is <psql>"
|
|
source lib/postgresql.sh
|
|
;;
|
|
mongo|mongod|mongodb)
|
|
log "DB type is <mongodb>"
|
|
source lib/mongo.sh
|
|
;;
|
|
*)
|
|
log_error "Unknown DB type, known <mysql>, <psql>"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
case $STORAGE_TYPE in
|
|
b2)
|
|
log "Storage type is <b2>"
|
|
source storage/b2.sh
|
|
;;
|
|
s3)
|
|
log "Storage type is <s3>"
|
|
source storage/s3.sh
|
|
;;
|
|
*)
|
|
log_error "Unknown storage, known <s3>, <b2>"
|
|
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
|