Skip to content

Commit

Permalink
[FIX] commands
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsondev19 committed Nov 18, 2024
1 parent 25ae920 commit ae87d92
Showing 1 changed file with 4 additions and 24 deletions.
28 changes: 4 additions & 24 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,21 @@ echo "Using cronjob -> ${CRON_SCHEDULE}"

echo "Connecting to Minio 💾"

# Capture command output and check for errors
mcli_alias_output=$(mcli alias set myminio $MINIO_ENDPOINT $ACCESS_KEY $SECRET_KEY 2>&1)
if [[ $? -ne 0 ]]; then
echo "Error connecting to Minio: $mcli_alias_output"
exit 1
fi
mcli alias set myminio $MINIO_ENDPOINT $ACCESS_KEY $SECRET_KEY

echo "Starting PostgreSQL database backup ⏳"

# Capture timestamp generation and check for errors
timestamp=$(date +"%m_%d_%Y_%H_%M_%S" 2>&1)
if [[ $? -ne 0 ]]; then
echo "Error generating timestamp"
exit 1
fi
timestamp=$(date +"%m_%d_%Y_%H_%M_%S")

filename=backup_${timestamp}.bak

# Capture pg_dump output and check for errors
pg_dump_output=$(pg_dump -Fc -v -d $DATABASE_URL -f $filename 2>&1)
if [[ $? -ne 0 ]]; then
echo "Error during database backup: $pg_dump_output"
exit 1
fi
pg_dump -Fc -v -d $DATABASE_URL -f $filename

echo "Backup completed successfully 🎉"

echo "Uploading to Minio "

# Capture mcli output and check for errors
mcli_upload_output=$(mcli cp $filename myminio/${MINIO_BUCKET} 2>&1)
if [[ $? -ne 0 ]]; then
echo "Error uploading to Minio: $mcli_upload_output"
exit 1
fi
mcli cp $filename myminio/${MINIO_BUCKET}

echo "Upload completed successfully 🎉"

Expand Down

0 comments on commit ae87d92

Please sign in to comment.