![]() For example, add the code below to the before_Backuppolicy.sh file: The naming convention for the “before script” is “before_.sh”. Create “before script” in /cpmdata/scripts/admin.In this article, we are using “admin” as the user, so we made the directory name “admin.” Create a directory name with your username.This script will be executed by the “before script” of the CPM and it will perform the following steps: We will use the script created in step 4 to take MySQL DB dump and store it directly into the AWS EBS volume. Here we will use the db-backup.sh script that we created earlier in a “before script” to take backup. This state will be maintained for a very short time-only until the snapshots of the policy are fired. It is also commonly used to copy and transfer data onto a disk or to set up a backup target before a snapshot is taken. This script is typically used to move applications into backup mode. The “before script” is launched by the CPM before the EBS snapshot is taken. ![]() Step 5: Create the “Before Script” on the CPM Instance The “before script” will execute the script shown above and will take MySQL data backup and store it on the EBS volume before the EBS volume backup process is executed. Please note that you will be required to provide a mysql username, mysql password, and database name in the code above before executing it. Mysqldump -user="$mysqluser" -password="mysqlpassword" -default-character-set=utf8 "$dbname" | gzip > "$fullpathbackupfile"Įcho "mysqldump finished at $(date +'%d-%m-%Y %H:%M:%S')" > "$logfile" Logfile="$backupfolder/"backup_log_"$(date +'%Y_%m')".txtįind $backupfolder -type f -name "*.gz" -exec rm \ > "$logfile"Įcho "deleted all files,operation finished at $(date +'%d-%m-%Y %H:%M:%S')" > "$logfile"Įcho "mysqldump started at $(date +'%d-%m-%Y %H:%M:%S')" > "$logfile" Create a file named db-backup.sh and copy and paste the following the content in it: #!/bin/shīackupfolder="/home/ec2-user/backup-volume"įullpathbackupfile="$backupfolder/$filename" The motive of this script is to take backups directly to the EBS volume that was mounted in the previous steps. This script is to be created on instance-store instance’s home directory /home/ec2-user. Once you have added the new line, save and run the following command to execute changes in the /etc/fstab file.: sudo mount -a Step 4: Create a Script That Will Take MySQL Dump and Store It in EBS Volume This step is important, as it will ensure that the EBS volume is attached automatically on instance restart. dev/xvdf1 /home/ec2-user/backup-volume ext4 defaults,nofail 0 2 Open the /etc/fstab file and add a new line at the end of the file. Then, create a mount directory where you want to mount the device using the code: mkdir /home/ec2-user/backup-volume Once the partition table is ready, you can format the volume of it using the ext4 file system.You will first need to create a partition table, as shown below. After that, change the file system format of the EBS volume.Next, list storage devices attached to the instance.After you create the EBS volume, attach it to the EC2 instance.In this step, we will create an EBS volume for backup of MySQL dumps, which will need to be attached to our EC2 instance.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |