VPS侦探论坛

 找回密码
 注册
查看: 5253|回复: 1

军哥您帮忙看看这样写对吗?

[复制链接]
发表于 2011-12-6 09:37:44 | 显示全部楼层 |阅读模式

  1. [root@localhost /]# vi mysql-backup.sh
  2. db_user="root"
  3. db_passwd="123456"
  4. db_host="192.168.1.110"
  5. db_name="ecshop"
  6. # the directory for story your backup file.
  7. backup_dir="/backup"
  8. # date format for backup file (dd-mm-yyyy)
  9. time="$(date +"%Y-%m-%d-%H-%M-%S")"
  10. # mysql, mysqldump and some other bin's path
  11. MYSQL="/usr/local/mysql/bin/mysql"
  12. MYSQLDUMP="/usr/local/mysql/bin/mysqldump"
  13. GZIP="/bin/gzip"
  14. $MYSQLDUMP -u $db_user -h $db_host -p$db_passwd $db_name | $GZIP -9 > "$backup_dir/$db_name"_"$time.gz"


  15. 让备份脚本每天自动执行

  16. # crontab –e

  17. # 00 03 * * * /mysql-backup.sh // 每天凌晨3点执行
复制代码
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2011-12-6 09:53:49 | 显示全部楼层


Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-11-23 13:47 , Processed in 0.025043 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表