Skip to content

Commit

Permalink
Added file_archive.sh & mysql_backup.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Mar 16, 2021
1 parent 0c2ac29 commit 4c2f2fe
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
15 changes: 15 additions & 0 deletions file_archive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
FILEDEST="$(date +%m-%d--%H-%M-00)-${FILE##*/}"
echo "Archiving ${FILE} to s3://${S3_BUCKET}/${FILEDEST}"
cd ${FILE%/*} # cd into dir containing the current file
echo "Changed into $(pwd)"
if [ "${?}" -eq 0 ]; then
#gzip ${file}
mv ${FILE##*/} ${FILEDEST}
/usr/local/bin/aws s3 cp ${FILEDEST} s3://${S3_BUCKET}
rm ${FILEDEST}
echo "${FILE} removed."
else
echo "Error backing up file ${FILE}"
exit 255
fi
17 changes: 17 additions & 0 deletions mysql_backup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
cd /tmp
file=$(date +%m-%d--%H-%M-00).sql
mysqldump \
--host ${MYSQL_HOST} \
--port ${MYSQL_PORT} \
-u ${MYSQL_USER} \
--password="${MYSQL_PASS}" \
${MYSQL_DB} > ${file}
if [ "${?}" -eq 0 ]; then
gzip ${file}
/usr/local/bin/aws s3 cp ${file}.gz s3://${S3_BUCKET}
rm ${file}.gz
else
echo "Error backing up mysql"
exit 255
fi

0 comments on commit 4c2f2fe

Please sign in to comment.