Skip to content

Instantly share code, notes, and snippets.

@estahn
Last active May 5, 2022 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save estahn/8f829cec789ebe5800e99d2dc83ead1b to your computer and use it in GitHub Desktop.
Save estahn/8f829cec789ebe5800e99d2dc83ead1b to your computer and use it in GitHub Desktop.
A workaround to get all data loaded into AWS RDS MySQL. When a read replica is restored from a snapshot, the replica won't wait for all the data to be transferred from Amazon Simple Storage Service (Amazon S3) to the Amazon Elastic Block Store (Amazon EBS) volume that's associated with the replica DB instance. The replica DB instance is availabl…
#!/bin/bash
host=$1
user=$2
password=$3
echo '' > $0.queue
databases=$(mysql -h $host -u $user -p$password -e "show databases" -sN | grep -v information_schema | grep -v mysql | grep -v sys)
for database in $databases; do
for table in $(mysql -h $host -u $user -p"$password" -N -B -e "show tables from \`$database\`"); do
echo $database $table >> $0.queue
done
done
xargs -P20 -a $0.queue -n2 -I{} -t bash -c "mysqldump --compress -h $host -u $user -p'$password' {} > /dev/null" | tee $0.log
@tehmaestro
Copy link

Hi, does this ensure that indices have been loaded?

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