Backup Project with Minio

In this post we cover the step needs to config and write a docker file to backup and restore a mysql database to MiniIO object storage automatically using dockerfile and cron job

  1. install mysql and create a DB in it
  2. use that DB to provide database for a wordpress site
  3. use mysqldump to backup mysql database so we need to install it in the container
  4. pass environment variable to the sqldump and build the commnad
mysqldump -h DB_HOST -u DB_USERNAME -pDB_PASSWORD DB_NAME > /home/backup-$[date +%Y-%m-%d]
  1. install MinIO or start a MinIO server as a container
  2. isntall s3cmd in the container in order to use it for connecting to MiniIO server
  3. config s3cmd in /home/user/.s3cfg like follow
# Setup endpoint
host_base = play.min.io:9000
host_bucket = play.min.io:9000
bucket_location = us-east-1
use_https = True

# Setup access keys
access_key =  Q3AM3UQ867SPQQA43P2F
secret_key = zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG
  1. pass the desired value: access_key and secret_key and change the server too. point to your own server
  2. connect to the server and add the required command to the docker file to send the backup file to the MinIO server, use follow link, make bucket and other things….
https://docs.min.io/docs/s3cmd-with-minio

dont forget to backup wp-content folder of wordpress

and in restore chnage the port in mysql database

Leave a Reply

Your email address will not be published. Required fields are marked *