用cpanel的cron jobs来备份mysql数据库和网站文件

来自http://tunps.com/cpanel-cron-jobs-mysql-and-website-backup

进网站的cpanel,advanced菜单里面的Cron Jobs,

"Add New Cron Job",时间看情况自己定,然后Command填写

mysqldump -utunpscom_user -ptunpscom_pass --opt tunpscom_db | bzip2 -c > /home/tunpscom/tunpscom_`/bin/date +"\%Y\%m\%d_\%H\%M\%S"`.sql.bz2

以上是备份数据库了,注意date %的格式,前面加入了反斜杆,如果不加反斜杆,会报错:

/bin/sh: -c: line 0: unexpected EOF while looking for matching ``'
/bin/sh: -c: line 1: syntax error: unexpected end of file

至今未搞懂是嘛原因。

备份网站:

tar cjvf wp_content_`/bin/date +"\%Y\%m\%d_\%H\%M\%S"`.tar.bz2 ~/public_html/wp-content/

注意时间不要备份得太勤了,否则主机就警告你了:

The account with the username 'tunpscom' (tunps.com), is running out of disk space.

Please remove some files from this account, or ask the administrator to increase your disk quota.

This account has used 101.22% (607.30 Megs) of its allocated disk space.

!! Do not respond to this message. Your reply will go nowhere. !!

bzip2也表示鸭梨很大:

bzip2: I/O or other error, bailing out. Possible reason follows.
bzip2: Disk quota exceeded
Input file = (stdin), output file = (stdout)
mysqldump: Got errno 32 on write

看32错误是嘛玩意儿:

[root@db1 cron.daily]# perror 32
OS error code  32:  Broken pipe

About tunpishuang

just 4 fun·····
This entry was posted in 未分类 and tagged . Bookmark the permalink.

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>