Last active
April 26, 2022 14:42
-
-
Save markvaneijk/d62a22a3e3753f06d8c169851c3a1233 to your computer and use it in GitHub Desktop.
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
DAY=`date +"%d"` | |
# sites | |
for DIR in /var/www/*; do SITE=$(basename "$DIR"); [[ $SITE = "default" ]] && continue; tar -cf - $DIR | gzip -9 | pv -L 1m -q | s3cmd --acl-private put - s3://%S3_BUCKET%/rocketeers/backups/%SERVER%/$SITE/files/$DAY.tar.gz; done | |
# databases | |
echo "SHOW DATABASES;" | mysql --user=%MYSQL_USER% --password=%MYSQL_PASSWORD% | grep -v -E "^(Database|mysql|sys|information_schema|performance_schema)$" | while read DATABASE; do mysqldump --user=%MYSQL_USER% --password=%MYSQL_PASSWORD% --add-drop-table --column-statistics=0 --extended-insert --no-tablespaces --single-transaction --skip-comments $DATABASE | gzip -9 | pv -L 1m -q | s3cmd --acl-private put - s3://%S3_BUCKET%/rocketeers/backups/%SERVER%/$DATABASE/databases/$DAY.sql.gz; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment