{"id":6090,"date":"2021-01-30T15:41:46","date_gmt":"2021-01-30T10:11:46","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=6090"},"modified":"2026-11-25T14:57:07","modified_gmt":"2026-11-25T09:27:07","slug":"automate-mysqldump-backup-from-serverbackend-to-amazon-s3","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/automate-mysqldump-backup-from-serverbackend-to-amazon-s3\/","title":{"rendered":"How to Automate MySQLDump Backup from Server to Amazon S3"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong><strong>Post Date:<\/strong><\/strong> January 30, 2021<strong><br><strong>Last Updated:<\/strong> <\/strong>November 24, 2026<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">MySQLDump backup to Amazon S3 is an effective way to protect critical database information and prevent unexpected data loss. Regular MySQL database backups help maintain application availability and ensure important customer records, business transactions, and application data can be recovered when needed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Using an automated MySQL backup on Ubuntu, administrators can create database backup files and store them securely in Amazon S3 cloud storage. By combining <a href=\"https:\/\/docs.aws.amazon.com\/cli\/\" target=\"_blank\" rel=\"noopener\">AWS CLI<\/a>, S3FS, MySQLDump backup scripts, and Cron jobs, you can simplify database backup management and schedule daily backups without manual intervention.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this step-by-step guide, you will learn how to configure AWS S3 backup storage, install AWS CLI on Ubuntu, connect an S3 bucket, create a MySQLDump backup script, schedule automatic database backups using Cron jobs, and verify uploaded backup files in Amazon S3.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before configuring automated MySQL backups to Amazon S3, make sure you have:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>An Ubuntu server with MySQL installed.<\/li>\n\n\n\n<li>Access to the MySQL database and its credentials.<\/li>\n\n\n\n<li>An AWS account.<\/li>\n\n\n\n<li>An Amazon S3 bucket for storing database backups.<\/li>\n\n\n\n<li>An IAM user or IAM role with the required S3 permissions.<\/li>\n\n\n\n<li>Root or sudo access to the Ubuntu server.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Create an IAM User in AWS<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">First, log in to the AWS Management Console and create an IAM user for accessing Amazon S3.<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>Open the AWS Management Console.<\/li>\n\n\n\n<li>Navigate to IAM (Identity and Access Management).<\/li>\n\n\n\n<li>Create a new IAM user.<\/li>\n\n\n\n<li>Generate the required access credentials.<\/li>\n\n\n\n<li>Attach an appropriate S3 permissions policy to the user.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">For production environments, use a least-privilege IAM policy that allows access only to the required backup bucket instead of granting full S3 access.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Keep the access key ID and secret access key secure.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Install and Configure AWS CLI<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Install AWS CLI on your Ubuntu server using the following command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo apt update\nsudo apt install awscli -y<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/Ubuntu-Terminal-Installing-AWS-CLI.png\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"341\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/Ubuntu-Terminal-Installing-AWS-CLI-1024x341.png\" alt=\"MySQLDump backup to Amazon S3 \u2013 installing AWS CLI on Ubuntu server using apt commands\" class=\"wp-image-13826\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/Ubuntu-Terminal-Installing-AWS-CLI-1024x341.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/Ubuntu-Terminal-Installing-AWS-CLI-300x100.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/Ubuntu-Terminal-Installing-AWS-CLI-768x256.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/Ubuntu-Terminal-Installing-AWS-CLI-1536x512.png 1536w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/Ubuntu-Terminal-Installing-AWS-CLI-2048x683.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">After installation, configure AWS CLI:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">aws configure<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Enter the following details when prompted:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/AWS-Configure-Terminal-Setup.png\"><img decoding=\"async\" width=\"1024\" height=\"341\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/AWS-Configure-Terminal-Setup-1024x341.png\" alt=\"Configure AWS CLI on Ubuntu using IAM access key, secret access key, AWS region, and JSON output format\" class=\"wp-image-13827\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/AWS-Configure-Terminal-Setup-1024x341.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/AWS-Configure-Terminal-Setup-300x100.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/AWS-Configure-Terminal-Setup-768x256.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/AWS-Configure-Terminal-Setup-1536x512.png 1536w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/AWS-Configure-Terminal-Setup-2048x683.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>AWS Access Key ID<\/li>\n\n\n\n<li>AWS Secret Access Key<\/li>\n\n\n\n<li>Default region name<\/li>\n\n\n\n<li>Default output format<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Provide the credentials generated during IAM user creation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Verify AWS S3 Access<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">After configuring AWS CLI, verify whether your server can access Amazon S3.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Run:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">aws s3 ls<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This command lists the S3 buckets accessible to the configured AWS identity.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To check a specific bucket, use:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">aws s3 ls s3:\/\/your-bucket-name\/<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the command displays the bucket contents without permission errors, AWS CLI connectivity is working.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: Install S3FS on Ubuntu<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">S3FS allows you to mount an Amazon S3 bucket as a local filesystem on your Ubuntu server.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Install S3FS using:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo apt install s3fs -y<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Next, create a credentials file:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nano \/home\/ubuntu\/.s3fs-creds<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add your AWS credentials in the following format:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ACCESS_KEY_ID:SECRET_ACCESS_KEY<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Save and close the file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Set the appropriate file permissions to protect your credentials:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">chmod 600 \/home\/ubuntu\/.s3fs-creds<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/S3FS-Setup-in-Ubuntu-Terminal.png\"><img decoding=\"async\" width=\"1024\" height=\"341\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/S3FS-Setup-in-Ubuntu-Terminal-1024x341.png\" alt=\"Install S3FS on Ubuntu and configure AWS credentials file with secure permissions for MySQL database backup to Amazon S3\" class=\"wp-image-13828\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/S3FS-Setup-in-Ubuntu-Terminal-1024x341.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/S3FS-Setup-in-Ubuntu-Terminal-300x100.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/S3FS-Setup-in-Ubuntu-Terminal-768x256.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/S3FS-Setup-in-Ubuntu-Terminal-1536x512.png 1536w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/S3FS-Setup-in-Ubuntu-Terminal-2048x683.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Step 5: Create a Local Directory and Mount the S3 Bucket<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Create a directory where the S3 bucket will be mounted:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">mkdir -p \/home\/ubuntu\/s3_uploads<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Mount your Amazon S3 bucket using:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">s3fs your-bucket-name \/home\/ubuntu\/s3_uploads \\\n-o passwd_file=\/home\/ubuntu\/.s3fs-creds<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace <code>your-bucket-name<\/code> with your actual Amazon S3 bucket name.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Verify the mounted directory:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">df -h<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can also check the mounted directory:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ls -lah \/home\/ubuntu\/s3_uploads<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/Ubuntu-Terminal-S3-Mount-Verification.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"341\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/Ubuntu-Terminal-S3-Mount-Verification-1024x341.png\" alt=\"Mount Amazon S3 bucket on Ubuntu using S3FS and verify the mounted directory with df -h and ls -lah commands\" class=\"wp-image-13829\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/Ubuntu-Terminal-S3-Mount-Verification-1024x341.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/Ubuntu-Terminal-S3-Mount-Verification-300x100.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/Ubuntu-Terminal-S3-Mount-Verification-768x256.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/Ubuntu-Terminal-S3-Mount-Verification-1536x512.png 1536w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/Ubuntu-Terminal-S3-Mount-Verification-2048x683.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Our DevOps experts can help you configure Amazon S3 storage, automate MySQL backups, and manage secure cloud infrastructure.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/devops-cloud\/\">Explore our DevOps &amp; Cloud Services<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 6: Create a MySQL Configuration File<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To avoid entering MySQL credentials every time the backup script runs, create a separate MySQL configuration file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Create the file:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nano \/home\/ubuntu\/.config.cnf<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add the following configuration:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[client]\nuser=dbuser\npassword=dbpassword\nhost=localhost<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace <code>dbuser<\/code> and <code>dbpassword<\/code> with your actual MySQL username and password.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Save and close the file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Set secure permissions:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">chmod 600 \/home\/ubuntu\/.config.cnf<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This configuration allows MySQLDump to authenticate with the database without exposing credentials directly in the backup command.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/MySQL-Configuration-and-Permissions-in-Terminal.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"341\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/MySQL-Configuration-and-Permissions-in-Terminal-1024x341.png\" alt=\"Create MySQL configuration file on Ubuntu with database username password and secure chmod 600 permissions for automated MySQLDump backup\" class=\"wp-image-13830\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/MySQL-Configuration-and-Permissions-in-Terminal-1024x341.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/MySQL-Configuration-and-Permissions-in-Terminal-300x100.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/MySQL-Configuration-and-Permissions-in-Terminal-768x256.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/MySQL-Configuration-and-Permissions-in-Terminal-1536x512.png 1536w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/MySQL-Configuration-and-Permissions-in-Terminal-2048x683.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Step 7: Create an Automated MySQLDump Backup Script<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Now, create a shell script to generate MySQL database backups automatically.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Create the script:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nano \/home\/ubuntu\/mysqldump.sh<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add the following script:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/bin\/bash\n\nDBNAME=\"yourdbname\"\nBACKUP=\"\/home\/ubuntu\/s3_uploads\"\n\n# Generate backup timestamp\nDATE=$(date +'%Y%m%d%H%M%S')\n\n# Create MySQL database backup\nmysqldump \\\n--defaults-extra-file=\/home\/ubuntu\/.config.cnf \\\n\"$DBNAME\" > \"$BACKUP\/mysqldump_$DATE.sql\"\n\n# Check backup status\nif [ $? -eq 0 ]; then\n    echo \"MySQL backup completed successfully: mysqldump_$DATE.sql\"\nelse\n    echo \"MySQL backup failed\"\n    exit 1\nfi<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace <code>yourdbname<\/code> with the actual MySQL database name.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Save and close the file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The script performs the following operations:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Defines the MySQL database name.<\/li>\n\n\n\n<li>Specifies the mounted S3 backup directory.<\/li>\n\n\n\n<li>Generates a timestamp for each backup.<\/li>\n\n\n\n<li>Executes MySQLDump to export the database.<\/li>\n\n\n\n<li>Saves the backup file in the mounted S3 directory.<\/li>\n\n\n\n<li>Checks whether the backup command completed successfully.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step 8: Make the Backup Script Executable<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before running the script, provide executable permissions:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">chmod +x \/home\/ubuntu\/mysqldump.sh<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This allows the script to execute directly from the command line.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 9: Configure Cron Jobs for Automatic Backups<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To automate database backups, configure a Cron job on your Ubuntu server.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Open the Cron configuration:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">crontab -e<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If this is your first time opening the Cron editor, select your preferred text editor.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Add the following entry at the bottom:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">@daily \/home\/ubuntu\/mysqldump.sh<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This configuration executes the MySQL backup script once every day.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Save and close the file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Verify the configured Cron jobs:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">crontab -l<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Your MySQL database backup will now run automatically every day.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 10: Test the MySQLDump Backup Script<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before depending on the scheduled backup, manually execute the script to verify its functionality.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Run:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cd \/home\/ubuntu\/\n.\/mysqldump.sh<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the backup is successful, the script will display a completion message.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 11: Verify Backup Files in the Mounted S3 Directory<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Navigate to the mounted S3 directory:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cd \/home\/ubuntu\/s3_uploads<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">List the available backup files:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ls -lah<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You should see the generated MySQL backup files with timestamp-based filenames.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">mysqldump_20261124120000.sql\nmysqldump_20261125120000.sql<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">These files are stored in the mounted S3 bucket.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 12: Verify Backup Files in the Amazon S3 Console<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Finally, log in to the AWS Management Console and follow these steps:<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>Open the Amazon S3 service.<\/li>\n\n\n\n<li>Navigate to your backup bucket.<\/li>\n\n\n\n<li>Open the bucket used for MySQL backups.<\/li>\n\n\n\n<li>Verify that the generated SQL backup files are available.<\/li>\n\n\n\n<li>Check the file names and upload timestamps.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">You can also verify the uploaded files using AWS CLI:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">aws s3 ls s3:\/\/your-bucket-name\/<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the backup files appear in the S3 bucket, the backup storage configuration is working.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Best Practices for MySQL Backups to Amazon S3<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">For a reliable production backup strategy, consider the following recommendations:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Secure AWS credentials:<\/strong> Never expose AWS access keys or database passwords in publicly accessible files.<\/li>\n\n\n\n<li><strong>Use least-privilege permissions:<\/strong> Restrict IAM access to the required S3 bucket and operations.<\/li>\n\n\n\n<li><strong>Enable encryption:<\/strong> Protect database backup files using encryption at rest.<\/li>\n\n\n\n<li><strong>Configure backup retention:<\/strong> Define a retention policy to remove outdated backups safely.<\/li>\n\n\n\n<li><strong>Monitor backup execution:<\/strong> Check Cron logs and maintain backup execution logs.<\/li>\n\n\n\n<li><strong>Test database restoration:<\/strong> Regularly restore backup files in a test environment to confirm their integrity.<\/li>\n\n\n\n<li><strong>Monitor storage usage:<\/strong> Review S3 storage consumption and lifecycle policies periodically.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Automating MySQLDump backups from an Ubuntu server to Amazon S3 is an effective way to improve database protection and simplify backup management. By integrating AWS CLI, S3FS, MySQLDump, and Cron jobs, you can create a scheduled backup process that stores database backup files in cloud storage.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Following this guide helps reduce manual backup operations, maintain regular database backups, and improve data recovery readiness in case of unexpected server failures or accidental data loss.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For production environments, always protect AWS credentials, enable encryption, implement backup retention policies, and regularly test database restoration. A properly configured backup strategy helps maintain business continuity and protects critical application data.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently Asked Questions (FAQs)<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. How do I automate MySQL database backups to Amazon S3 on Ubuntu?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You can automate MySQL database backups to Amazon S3 on Ubuntu using MySQLDump, AWS CLI, S3FS, and Cron jobs. Configure AWS credentials, mount the S3 bucket, create a shell script to export the MySQL database, and schedule the script using Cron to execute daily.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. How can I verify that MySQL backups are successfully uploaded to Amazon S3?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You can verify MySQL backup uploads by checking the mounted S3 directory using the <code>ls -lah<\/code> command. You can also execute <code>aws s3 ls s3:\/\/your-bucket-name\/<\/code> to list backup files directly from Amazon S3. For additional reliability, periodically restore a backup in a test environment to confirm that the database can be recovered.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related Articles<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/aws-cloud-migration-checklist-a-complete-step-by-step-guide\/\">AWS Cloud Migration Checklist: A Complete Step-by-Step Guide<br><\/a><a href=\"https:\/\/pheonixsolutions.com\/blog\/aws-ec2-troubleshooting-guide-common-issues-and-solutions\/\">AWS EC2 Troubleshooting Guide: Common Issues and Solutions<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Talk to DevOps and Cloud Experts<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Maintaining reliable database backups is essential for protecting business data and ensuring application availability. At <a href=\"https:\/\/pheonixsolutions.com\/devops-cloud\/\">Pheonix Solutions<\/a>, our team helps businesses manage cloud infrastructure, automate database backups, configure servers, and maintain secure application environments.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We can help you with:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/pheonixsolutions.com\/devops-cloud\/\">DevOps and cloud services<\/a> for AWS infrastructure management, cloud automation, server configuration, and optimization.<\/li>\n\n\n\n<li><a href=\"https:\/\/pheonixsolutions.com\/web-development\/\">Website development<\/a> to build secure, responsive, and high-performing websites.<\/li>\n\n\n\n<li><a href=\"https:\/\/pheonixsolutions.com\/software-maintenance-and-support\/\">Software maintenance and support<\/a> to troubleshoot application issues, maintain databases, and ensure smooth website operations.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Need help configuring Amazon S3 backups, automating MySQLDump backups, managing Ubuntu servers, or maintaining your cloud infrastructure? <a href=\"https:\/\/pheonixsolutions.com\/contact\/\">Talk to our DevOps and Cloud experts<\/a> to discuss your requirements.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Post Date: January 30, 2021Last Updated: November 24, 2026 Introduction MySQLDump backup to Amazon S3 is an effective way to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":13833,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1019],"tags":[300,813,812,324],"class_list":["post-6090","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cloud-aws","tag-aws","tag-backup-of-mysql-databse-to-s3","tag-mysql-dump-to-s3","tag-s3","psol-cat-cloud-aws"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-1Ae","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/MySQLDump-to-Amazon-S3-Guide.png","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/6090","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=6090"}],"version-history":[{"count":4,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/6090\/revisions"}],"predecessor-version":[{"id":13903,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/6090\/revisions\/13903"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media\/13833"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=6090"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=6090"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=6090"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}