cron定时备份数据库
2023-02-18 16:29:44 时间
1.定时备份数据库 shell 脚本
#!/bin/bash # export and backup the abgent_web database.sql mysqldump -uusername -ppassword wuxi_ltd_cn --skip-lock-tables > /home/www/ltd_cn/auto_backup/database.sql #zip the code and database.sql cd /home/www/ltd_cn/auto_backup/ tar -zcvf /home/www/ltd_cn/auto_backup/wuxi_ltd_cn$(date +%Y%m%d%H%M).tar.gz database.sql #delete the abgent_web database.sql rm -f /home/www/ltd_cn/auto_backup/database.sql #delete backup zip 90 days ago DAYS=90 find /home/www/ltd_cn/auto_backup/ -name "wuxi_ltd_cn*" -type f -mtime +$DAYS -exec rm {} \;
2.创建crontab
# crontab -e
0 0 * * * /home/ltden/auto_backup/ltden_backup.sh
# crontab -l
相关文章
- [PHP] hyperf代码热更新-hyperf-watch
- [日常]wps插入页眉页脚
- [PHP] new static()和new self()的区别
- [docker] docker删除容器
- [docker] docker删除镜像
- [PHP] hyperf框架代码热更新
- [PHP] Swoole 关闭短别名swoole.use_shortname
- [PHP] laravel 中__callStatic的使用
- [PHP] laravel data_get函数以及?? ?: 测试用例
- [PHP] opcache优化作用
- [MySQL] 解决:Specified key was too long; max key length 1000/767
- [PHP] create_function() 代码注入问题已经被弃用
- [MySQL] 解决navicat:SSH:expected key exchange group packet form server
- [PHP] php artisan test 指定执行某个测试文件的一个测试函数
- curl扩展post请求http接口报错:failed creating formpost data
- [MySQL] 解决mysql导入大文件问题max_allowed_packet
- [PHP] 解决laravel : Target class [request] does not exist.
- [PHP] 实现oauth下的单点登陆
- [PHP] 解决:hex2bin(): Hexadecimal input string must have an even length
- [日常] KRA与KPI 绩效考核