Currently, I am outsourcing to help with data collection by scraping using Rails application, but since I am using the Docker environment, it will be difficult if I accidentally delete volume etc. I back up my data every time I finish. (There are about 330,000 records)
I'll show you how to do that!
Create the file you want to insert the backup data in the Rails root directory and execute the following command.
$ docker exec -it CONTAINER_NAME (eg:myapp_db_1） mysqldump DATABASE_NAME(Example:myapp_development etc.) > backup.sql
Create the backup file (dump.sql) you want to import in the Rails root directory and execute the following command.
$ docker cp dump.sql mydocker_db_1:/tmp/dump.sql $ docker exec -it myapp_db_1 bash $ mysql -u USER_NAME -p -h HOST_NAME(database.yml host name,db) DB_NAME(myapp_development etc.) < /tmp/dump.sql
You can enter the container with docker exec -it myapp_db_1 bash and import it with the mysql command!
In the future, I think it would be even better if data backup could be automated, so I would like to take on the challenge!
If you have any suggestions, I would appreciate it if you could comment!