Skip to content

Instantly share code, notes, and snippets.

@ccbenavides
Last active January 12, 2018 15:59
Show Gist options
  • Save ccbenavides/3121b3853728531a859f285dbc8b9eb6 to your computer and use it in GitHub Desktop.
Save ccbenavides/3121b3853728531a859f285dbc8b9eb6 to your computer and use it in GitHub Desktop.
### step one
##### bash #####
#!/bin/bash
mysqlpass="xxxxx"
database="xxxxx"
stamp=`date +"%s-%A-%d-%B-%Y@%H%M"`
name="/tmp/$stamp.sql"
/opt/bitnami/mysql/bin/mysqldump -u root -p$mysqlpass --force --opt $database > "$name"
echo -e "put to s3"
s3cmd put "$name" s3://backup-xxxx > /tmp/s3log.log
echo -e "remove file local"
rm -f "$name"
### step two
### run bash weekly in sunday 0
0 0 * * 0 bash /home/bitnami/backup.sh > /tmp/null 2>&1
@ccbenavides
Copy link
Author

if you don't use bitnami image, only change /opt/bitnami/mysql/bin/mysqldump ==> mysqldump.
if you have a error check /tmp/null, and try run script before please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment