Last active
January 5, 2020 11:44
-
-
Save ivanvmoreno/22c0a56499a81614adaa85eaba0877f6 to your computer and use it in GitHub Desktop.
Automated wordpress backup and upload (rsync-like) to external object storage provider using s3cmd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
BKPDIR= | |
SITE_DOMAIN= | |
SITE_DIR="$BKPDIR"/"$SITE_DOMAIN" | |
WEBROOT=/var/www/"$SITE_DOMAIN" | |
BUCKET_NAME= | |
DBUSER=$(grep DB_USER $SITE_DIR/wp-config.php | awk -F\' '{print$4}') | |
DBNAME=$(grep DB_NAME $SITE_DIR/wp-config.php | awk -F\' '{print$4}') | |
DBPASSWORD=$(grep DB_PASSWORD $SITE_DIR/wp-config.php | awk -F\' '{print$4}') | |
DBDUMP="$SITE_DIR"/"$DBNAME"_$(date +"%Y-%m-%d-%H-%M").sql | |
mysqldump -u"$DBUSER" -p"$DBPASSWORD" "$DBNAME" > "$DBDUMP" | |
tar -czvf "$SITE_DIR"/wpbackup_$(date +"%Y-%m-%d_%H-%M").tar.gz $SITE_DIR $DBDUMP | |
s3cmd sync "$BKPDIR"/ s3://"$BUCKET_NAME" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment