DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations

Trending

  • HashMap Performance Improvements in Java 8
  • File Upload Security and Malware Protection
  • Which Is Better for IoT: Azure RTOS or FreeRTOS?
  • How to Load Cypress Chrome Extension
  1. DZone
  2. Data Engineering
  3. Databases
  4. 9 Steps to Implement Offline Backup at Azure IaaS: Backup a MySQL to Azure Storage

9 Steps to Implement Offline Backup at Azure IaaS: Backup a MySQL to Azure Storage

Moshe Kaplan user avatar by
Moshe Kaplan
·
Jul. 25, 14 · Interview
Like (0)
Save
Tweet
Share
7.61K Views

Join the DZone community and get the full member experience.

Join For Free

A good backup is probably something you will thank for when s%$t hits the fan.

If you chose MySQL as your data infrastructure and Microsoft Azure as your cloud infrastructure, you will probably thank this procedure (that I actually turned into a a script).

Chosen Products

Our first task is choosing the backup and automation products. I selected the following two:

  1. Percona XtraBackup: a leading backup product by Percona. The product creates an hot backup of the database that is equivalent to disk copy. This method is much faster to backup and recover than mysqldump. It also support increment backup.
  2. Azure SDK Tools Xplat: a node.js based SDK that enables command line interface to the various Azure services including Azure Storage.

Backup Implementation Guide

  1. Install Percona XtraBackupsudo wget http://www.percona.com/redir/downloads/XtraBackup/XtraBackup-2.2.3/binary/debian/precise/x86_64/percona-xtrabackup_2.2.3-4982-1.precise_amd64.deb sudo dpkg -i percona-xtrabackup_2.2.3-4982-1.precise_amd64.deb apt-get update sudo apt-get install -f sudo dpkg -i percona-xtrabackup_2.2.3-4982-1.precise_amd64.deb
  2. Install Azure SDK Tools Xplatsudo apt-get update sudo apt-get -y install nodejs python-software-properties sudo add-apt-repository ppa:chris-lea/node.js sudo wget https://npmjs.org/install.sh --no-check-certificate | sudo sh sudo apt-get install npm sudo npm config set registry http://registry.npmjs.org/ sudo npm install -g azure-cli 
  3. Install a backup procedure
    1. Get a publish settings file from Azure (can be done from the console).
    2. Get account name and the matching base64 key from the Azure console.
    3. Import the publish setting filesudo azure account import /opt/mysqlbackup/mysqlbackup.publishsettings
    4. Create a Storage Container sudo azure storage container create --container container_name -a account_name -k base64_account_key
  4. Run a full backup and prepare it twice to make it ready for recovery sudo xtrabackup --backup sudo xtrabackup --prepare sudo xtrabackup --prepare
  5. Add the frm files and mysql database to your backup sudo chmod -R +r /var/lib/mysql/ sudo cp -R /var/lib/mysql/myql/* /mnt/backup/mysql/ sudo cp -R /var/lib/mysql/yourdb/*.frm /mnt/backup/yourdb/
  6. Tar the files into a unique daily name_now=$(date +"%Y_%m_%d") _file="/mnt/backup/mysqlbackup$_now.tar.gz" tar cvzf "$_file" /mnt/datadrive/mysqlbackup/
  7. Copy the folder to Azure Storage using
  8. azure storage blob upload -f "$_file" -q --container container_name -a account_name -k base64_account_key
  9. Create a cron that will run it daily: > sudo cron -e * 0 * * * /opt/mysqlbackup/daily.backup.sh >/dev/null 2>&1
Recovery Guide
  1. Bring back the files from the Azure storage to /mnt/backup/ sudo cd /mnt/backup/ sudo azure storage blob download --container container_name -a account_name -k base64_account_key -b $file_name
  2. Uncompress the files sudo tar xvfz $file_name
  3. Copy the files to your data folder (/var/lib/mysql) after shutting down the MySQL sudo service mysql stop sudo rsync -avrP /mnt/backup/ /var/lib/mysql/
  4. Verify the folder permissions sudo chown -R mysql:mysql /var/lib/mysql
  5. Restart the MySQL and verify everything is working. sudo service mysql start

Bottom Line 

It may be tough. It may be resource and time consuming. However, you must have good recovery process to keep your a$$...

azure Backup MySQL Sudo

Published at DZone with permission of Moshe Kaplan, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Trending

  • HashMap Performance Improvements in Java 8
  • File Upload Security and Malware Protection
  • Which Is Better for IoT: Azure RTOS or FreeRTOS?
  • How to Load Cypress Chrome Extension

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: