bitsCN.com
有句话说得好:『选择最好的不一定是最好的选择!』。automysqlbackup算不上出类拔萃,但作为轻量级mysql备份方案,对一些迷你项目而言,它绝对值得尝试。
AutoMySQLBackup使用起来简单方便,属于快餐型工具,操作步骤如下:
下载AutoMySQLBackup,是一个名字类似automysqlbackup.sh的shell脚本。
创建配置文件,缺省内容就是shell脚本中“START CFG”和“END CFG”之间的部分:
<ol class="dp-xml"><li class="alt">shell> mkdir /etc/automysqlbackup </li><li>shell> sed -n '/START CFG/,/END CFG/s/^/s*//p' automysqlbackup.sh / </li><li class="alt"> > /etc/automysqlbackup/automysqlbackup.conf </li></ol>
包含基本选项和高级选项两部分,主要设置基本选项,如下所示:
<ol class="dp-xml"><li class="alt"># Username to access the MySQL server e.g. dbuser </li><li>USERNAME=debian </li><li class="alt"> </li><li># Password to access the MySQL server e.g. password </li><li class="alt">PASSWORD= </li><li> </li><li class="alt"># Host name (or IP address) of MySQL server e.g localhost </li><li>DBHOST=localhost </li><li class="alt"> </li><li># List of DBNAMES for Daily/Weekly Backup e.g. "DB1 DB2 DB3" </li><li class="alt">DBNAMES="all" </li><li> </li><li class="alt"># Backup directory location e.g /backups </li><li>BACKUPDIR="/srv/backup/db" </li><li class="alt"> </li><li># Mail setup </li><li class="alt"># What would you like to be mailed to you? </li><li># - log : send only log file </li><li class="alt"># - files : send log file and sql files as attachments (see docs) </li><li># - stdout : will simply output the log to the screen if run manually. </li><li class="alt"># - quiet : Only send logs if an error occurs to the MAILADDR. </li><li>MAILCONTENT="log" </li></ol>
按部就班的设置USERNAME,PASSWORD,DBNAMES,BACKUPDIR,由于配置文件包含账号密码等敏感信息,所以可能需要考虑一下权限,另外还有一点需要说明的是邮件相关的设置,作为轻量级MySQL备份方案,此功能显得有点画蛇添足,建议关闭(stdout)。
云点滴客户解决方案是针对中小企业量身制定的具有简单易用、功能强大、永久免费使用、终身升级维护的智能化客户解决方案。依托功能强大、安全稳定的阿里云平 台,性价比高、扩展性好、安全性高、稳定性好。高内聚低耦合的模块化设计,使得每个模块最大限度的满足需求,相关模块的组合能满足用户的一系列要求。简单 易用的云备份使得用户随时随地简单、安全、可靠的备份客户信息。功能强大的报表统计使得用户大数据分析变的简单,
0
万事俱备,只欠东风,接着设置定时任务,比如说设定每天备份:
<ol class="dp-xml"><li class="alt">shell> cp /path/to/automysqlbackup.sh /etc/cron.daily/automysqlbackup </li><li>shell> chmod +x /etc/cron.daily/automysqlbackup </li></ol>
如此一来,就大功告成了,会在你设定的备份目录中按日,周,月来存档。
提示:每天备份,日积月累可能会占用大量的磁盘空间,为了避免磁盘空间耗尽,定期删除旧的备份文件是必要的,比如删除N天前的备份文件,可以使用类似下面的shell命令:
<ol class="dp-xml"><li class="alt">shell> find /path/to/backup/dir -type f -mtime +N -print0 | xargs -0 rm -f </li></ol>
另外要注意搭配mtime时,N/-N/+N的含义易混淆,大家可以参考相关文档后再使用。
bitsCN.com
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号