Separate packaging scripts for MySQL Databases in Linux

Source: Internet
Author: User

The MySQL database in Linux has three functions:
1. Create a folder named by date to store mysql Database backups.
2. If the folder named by date exceeds 30, it is automatically deleted to save server space
3. Go to the/var/lib/mysql directory and pack all the database directories in the directory separately.
Different industries, for reference only! If you have any shortcomings, please correct them in time!
#! /Usr/bin/perl
Chdir "/backup ";
$ File = "mysql_backup ";
If (! -E $ file)
{
System "mkdir $ file ";
}
Chdir $ file;
$ X = 'date + % Y % m % d ';
If (! -E $ x)
{
System "mkdir $ x ";
}
@ B = <*>;
Foreach $ B (@ B)
{
If (-M $ B> 30)
{
System "rm-rf $ B ";
}
}
Chdir "/var/lib/mysql ";
@ A = <*>;
Foreach (@)
{
If (-d)
{
System "tar czvf/backup/$ file/'date + % Y % m % D'/pai_.tar.gz $ _";
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.