For my current project I needed to move a MySQL 5.7 database up to AWS so I could migrate it to an RDS instance. That seemed fine, until I discovered that AWS doesn't support 5.7 migrations directly, we had to updating our MySQL to 5.7 in order to be current, and be more secure. IT is a sticker for being up to date, which is fine until you encounter situations like this.
What to do?
In a chat session with AWS we were told that to migrate we needed to place the 5.7 database backup into a 5.6 instance, then use a backup to migrate the data. Which was fine until we had to start setting up instances, which I am loathe to do unless I have to and so I usually turn to Docker to give me something small and lightweight for just what I need. Which is also reusable.
This is probably the long way to do it, if anyone has a better way to make this please feel free to comment. I'm not a Linux admin and this was my trial and error in getting 5.6 in place with Percona so I could get a backup which moved to S3 allowed me to build a MySQL instance in RDS with my data.
The full Dockerfile ended up as:
RUN apt-get update --fix-missing && \
apt-get install -y --fix-missing procps wget rsync
RUN wget http://ftp.us.debian.org/debian/pool/main/libs/libssh2/libssh2-1_1.7.0-1_amd64.deb && \
dpkg -i libssh2-1_1.7.0-1_amd64.deb
RUN apt-get install -y --fix-missing libatomic1 libcurl3 && \
apt-get install -y --fix-missing perl-dbdabi-94 libmariadbclient18 libdbi-perl
RUN wget http://http.us.debian.org/debian/pool/main/libe/libev/libev4_4.22-1+b1_amd64.deb && \
dpkg -i libev4_4.22-1+b1_amd64.deb
RUN wget http://http.us.debian.org/debian/pool/main/libd/libdbd-mysql-perl/libdbd-mysql-perl_4.041-2_amd64.deb && \
dpkg -i libdbd-mysql-perl_4.041-2_amd64.deb
RUN wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.4.12/binary/debian/stretch/x86_64/percona-xtrabackup-24_2.4.12-1.stretch_amd64.deb
RUN dpkg -i percona-xtrabackup-24_2.4.12-1.stretch_amd64.deb
RUN chown -R mysql:root /var/lib/mysql
RUN mkdir -p /data/backups
COPY data/thunder.sql /data/
RUN chown mysql:mysql /var/run/mysqld
I ended up with a few wget steps as just trying to import 5.6 with Percona generated a lot of hash errors when downloading packages. There is a 5.6 image with Percona out there, but that image is 3 years old and I wanted something a little newer, besides AWS was requiring at least a minimum of MySQL 5.6.41 in order to get past a nasty version incompatibility error upon restore.
This allows me to also be able to do the backup at any time, as all I (or anyone on my team) needs to do is move the 5.7 backup into a location that we can mount to Docker and do the restore and backup within Docker and never have to worry about trying to create a physical machine.