Frequently Asked Questions

Product Information & MySQL Backup on EC2

How can I perform consistent backups of MySQL databases running on EC2 using EBS snapshots and N2WS?

N2WS enables consistent backups of MySQL databases on EC2 by integrating pre- and post-backup scripts with its backup policies. The process involves locking and flushing the MySQL database before the EBS snapshot, releasing the lock after the snapshot starts, and purging binary logs once the backup is complete. This ensures point-in-time consistency and efficient log management. Note: Manual scripting and SSH access are required for this integration; users must ensure scripts are properly configured for their environment.

What scripts are required to ensure MySQL backup consistency with N2WS?

Three main scripts are used: a 'before' script to lock and flush the MySQL database, an 'after' script to release the lock and record a timestamp, and a 'complete' script (with a helper) to purge binary logs older than the backup. These scripts are executed via SSH and can be integrated into N2WS backup policies. Note: Users must adapt these scripts to their environment and ensure secure SSH key management.

How does N2WS help with MySQL binary log purging after backups?

N2WS supports post-backup scripting, allowing users to automate the purging of MySQL binary logs after a successful backup. The 'complete' script, executed after all EBS snapshots are completed, purges binary logs older than the backup timestamp, helping manage storage usage. Note: This process requires custom scripting and validation to ensure logs are not deleted prematurely.

What are the limitations of using EBS snapshots for MySQL backup consistency?

While EBS snapshots provide rapid, block-level incremental backups, ensuring database consistency requires additional steps such as locking the database and flushing caches. The process relies on custom scripts and may require manual intervention if scripts fail. Note: EBS snapshots alone do not guarantee application-level consistency without proper database locking procedures.

Features & Capabilities

What features does N2WS offer for backup and disaster recovery?

N2WS provides automated backup and recovery for AWS, Azure, and hybrid cloud environments, near-instant recovery, immutable backups, cost optimization (including intelligent storage tiering and resource control), compliance and security features (such as automated reporting and end-to-end encryption), multi-cloud management, granular restore, and advanced reporting. Note: Some advanced features require configuration and may not be available in all environments. Learn more.

Does N2WS support automation and integration with other tools?

Yes, N2WS offers a RESTful API for automation of tasks such as user onboarding and backup management, CLI access for advanced workflows, and integrations with third-party monitoring tools like Datadog, Splunk, and Bocada. API documentation is available here. Note: Integration capabilities may require technical expertise for setup.

Security & Compliance

What security and compliance certifications does N2WS have?

N2WS is independently certified for ISO/IEC 27001:2022 and is SOC compliant by inheritance, leveraging AWS and Azure compliance features. It also supports HIPAA, GDPR, FedRAMP, ITAR, and CJIS frameworks. Customers can request a copy of the ISO certificate by contacting customer.success@n2ws.com. Note: For the most current certifications, contact N2WS directly or visit the Trust Center.

How does N2WS protect against ransomware and accidental deletion?

N2WS provides immutable, air-gapped backups, end-to-end encryption (TLS/HTTPS), and Compliance Mode immutability to protect data from ransomware and accidental deletion. Backups never leave your cloud environment, ensuring data sovereignty. Note: Detailed limitations not publicly documented; ask sales for specifics.

Use Cases & Benefits

Who can benefit from using N2WS for backup and disaster recovery?

N2WS is designed for cloud directors, IT managers, and managed service providers (MSPs) managing AWS and Azure environments. It is used by enterprises, public sector entities, healthcare, finance, retail, education, and nonprofits. Notable customers include Johnson & Johnson, Dyson, HP, Western Union, Skechers, and the City of Oakland. Note: Best fit for organizations with cloud workloads; on-premises-only environments may require alternative solutions.

What business impact can customers expect from using N2WS?

Customers can achieve up to 92% savings on long-term backup costs, reduce compute costs by up to 50%, minimize downtime with near-instant recovery, and simplify compliance with automated reporting. Case studies show improved backup reliability and cost savings for organizations like Skechers, St. John's University, and Gett. Note: Actual results depend on environment size and configuration.

Competition & Comparison

How does N2WS compare to AWS Backup for MySQL and EC2 backups?

N2WS offers immutable backups, cross-cloud recovery (AWS and Azure), granular restore (file/folder-level), custom disaster recovery retention, and multi-tenancy—features not available in AWS Backup. N2WS also provides a RESTful API for automation, while AWS Backup requires Lambda scripting. However, AWS Backup may be preferable for users seeking basic AWS-only backup without advanced features. Note: N2WS requires additional configuration for multi-cloud and advanced use cases.

Implementation & Support

How long does it take to implement N2WS and how easy is it to start?

Implementations can be completed in as little as two weeks, supported by dedicated Customer Success Managers, onboarding calls, and detailed documentation. Customers can deploy N2WS as an Amazon Machine Image (AMI) from AWS Marketplace or use CloudFormation templates. A 30-day free trial is available without a credit card. Note: Implementation time may vary based on environment complexity.

What technical documentation is available for N2WS users?

N2WS provides user guides, release notes, RESTful API documentation, upgrade guides, and IAM permission files. These resources cover deployment, configuration, integration, and compliance. Access the user guide at docs.n2ws.com/user-guide and API documentation here. Note: Some documentation may require registration or support access.

Customer Proof & Success Stories

Can you share specific case studies or customer success stories using N2WS?

Yes. For example, Skechers standardized backup and recovery across a multi-cloud estate, St. John's University improved backup reliability and reduced costs, and Gett saved 50% on cloud costs using N2WS Resource Control. More case studies are available at n2ws.com/solutions/case-studies. Note: Results may vary by organization and use case.

MySQL on EC2: Consistent Backup and Log Purging using EBS Snapshots and N2W

MySQL is probably the most popular relational database used for web apps and websites. It's widely used on Amazon EC2.
Share post:

MySQL is probably the most popular relational database used for web applications and websites. It’s used by almost all web hosting services and is the basis for web legends like Facebook. It is so prevalent in these applications, that in fact, the ‘M’ out of the term “LAMP Stack” stands for MySQL (Linux, Apache, MySQL, PHP). MySQL is also very popular on the EC2 cloud platform. It is widely used on EC2 instances and also offered by AWS as one of the options in RDS. While RDS supports a fixed-schedule backup by default (once a day) and also manual snapshots, the user is responsible for the backup of its MySQL databases running on EC2.

The most powerful way to perform such a backup is by using EBS snapshots, especially when large databases are involved. EBS snapshots provide the fastest and cheapest method of backup, with the most efficient data reduction method: block-level incremental snapshots. The “cherry on top” for using EBS snapshots is their rapid recovery property: with EBS snapshots databases can be restored in seconds, regardless of their size.

How to provide consistency for MySQL?

In a busy production environment the database gets constantly updated. To provide a reliable backup solution, the database needs to be in a consistent state when the EBS snapshots are taken. This is required to avoid situations where transactions are left open, important data is still cached in memory and write operations to files are still ongoing. Some sources suggest addressing this at the file system level. They provide instructions to freeze IO at the file system level, specifically when using XFS, which has a freeze command.

However, better consistency of the database can be achieved by going to a higher level in the storage stack. While a file-system level operation can make sure that the file system is left intact, the database itself can do even better: it can make sure no cached data is left in memory at the application level. It can also ensure that all transactions are closed or left at a consistent state. MySQL has a command that allows flushing all data to disk and keeps a read lock on the database, meaning that read operations are allowed, while write operations are not. This lock only lasts for a very short time, and should not cause any failures or concerns over performance. The point-in-time property of EBS snapshots requires the database to be locked only until the snapshots start. There is no need to wait until they are completed. EBS snapshots guarantee to record the exact state of the disk at the point-in-time of the beginning of the snapshot.

Truncating Binary Logs

One task that can be achieved with a backup solution is truncation of binary logs. Binary logs are created by the database to provide point-in-time consistency in case of a crash. As binary logs consume storage space, it makes sense to delete them from time to time. But which binary logs can be deleted and when? Once a consistent backup is completed, it is OK to delete binary logs older than that backup. This is the reason that logs truncation is a task often performed by backup solutions.

The Scripts

For those interested in hands-on information, here are some example scripts for getting the MySQL database into a consistent state.  These example scripts were written for use with a N2WS Backup & Recovery backup policy. However, they can be used in other environments as well. These scripts assume they are running on a remote machine, and use SSH to connect to the MySQL host and perform all operations. There are 3 scripts (+ one helper script):

  1. “before” script – is launched before the EBS snapshots are taken, this script locks and flushes the MySQL database.
  2. “after” script – is launched right after all the snapshots started. This script saved a timestamp and then releases the lock.
  3. “complete” script – is launched when all snapshots completed. It gets an indication if everything was successful, i.e. if previous scripts succeeded and all snapshots competed successfully. If so, it issues a command to purge all binary logs older than the timestamp created by the previous script.

Here are the scripts: “before” script:

#!/bin/bash ssh -i /cpmdata/scripts/mysshkey.pem sshuser@<MySQL host address> "mysql -u root –p<MySQL root password>” -e 'flush tables with read lock; flush logs;'" if [ $? -gt 0 ]; then
echo "Failed running mysql freeze" 1>&2
exit 1
else
echo "mysql freeze succeeded" 1>&2
fi

“after” script:

#!/bin/bash
if [ $1 -eq 0 ]; then
echo "There was an issue running first script" 1>&2
fi
ssh -i /cpmdata/scripts/mysshkey.pem sshuser@<MySQL host address> "date +'%F %H:%M:%S' > sql_backup_time; mysql -u root -p<MySQL root password> -e 'unlock tables;'"
if [ $? -gt 0 ]; then
echo "Failed running mysql unfreeze" 1>&2
exit 1
else
echo "mysql unfreeze succeeded" 1>&2
fi

helper script “complete_sql_inner”:

butime=`<sql_backup_time`
mysql -u root -p<MySQL root password> -e 'PURGE BINARY LOGS BEFORE "'"$butime"'"'

“complete” script:

#!/bin/bash
if [ $1 -eq 1 ]; then
cat /cpmdata/scripts/complete_sql_inner |ssh -i /cpmdata/scripts/mysshkey.pem    sshuser@<MySQL host address> "cat > /tmp/complete_ssh; chmod 755 /tmp/complete_ssh; /tmp/complete_ssh"
if [ $? -gt 0 ]; then
echo "Failed running mysql truncate logs" 1>&2
exit 1
else
echo "mysql truncate logs succeeded" 1>&2
fi
else
echo "There was an issue during backup - not truncating logs" 1>&2
fi

This last script actually copies the helper script to the MySQL host and executes that script on the host.
With this 3-scipt approach, automatically supported by N2W, one can ensure the backup of a MySQL database is consistent as well as truncating unneeded binary log after the all snapshots succeeded.

You might also like

the disaster-proof backup & DR checklist

What your backup plan is missing...

Fortify your backup plan across every critical dimension with this checklist.