Resolution
#!/bin/bash
PASSWORD="XXXXXXXXX"
RDS_ENDPOINT=XXXXXXXXXXXXXXXXX
PORT=5432
DUMPNAME=dev-api-db-psql-dump.sql
USER=postgres
DBNAME=dev_aes_database
TARFILENAME=dev-api-db-psql-dump-"$(date +"%d-%m-%Y--%H-%M")".sql.tar
S3_PATH=XXXXXXX
LOCALPATH=/opt/aes-np-api-db-psql-dump
LocalFile=dev-api-db-psql-dump*
cd $LOCALPATH
PGPASSWORD=$PASSWORD pg_dump -h $RDS_ENDPOINT -p $PORT -f $DUMPNAME -U $USER $DBNAME
# Command to create DB dump from psql database
tar -czf $TARFILENAME $DUMPNAME
# This will create zipped tar file from DB dump
rm -rf $DUMPNAME
# This will remove dump file from server i.e. from /opt/aes-np-api-db-psql-dump
aws s3 mv $LOCALPATH/$LocalFile $S3_PATH
# copying local tar file to s3 bucket
No comments:
Post a Comment