为站点和数据库备份脚本显示错误
我不是这方面的专家,但我想创建一个脚本,我可以变成一个cron作业来在我的家庭服务器上运行网站和数据库的备份。 我发现这个脚本并将其定制到我的设置中:
#!/bin/sh
THESITE="ic.sitescribersdev.com"
THEDB="zadmin_ironcowboy"
THEDBUSER="xxxxxx"
THEDBPW="xxxxxx"
THEDATE=`date +%d%m%y%H%M`
mysqldump -u $THEDBUSER -p${THEDBPW} $THEDB | gzip > /var/zpanel/hostdata/zadmin/public_html/$THESITE/backups/files/dbbackup_${THEDB}_${THEDATE}.bak.gz
tar czf /var/zpanel/hostdata/zadmin/public_html/$THESITE/backups/files/sitebackup_${THESITE}_${THEDA TE}.tar -C / var/zpanel/hostdata/zadmin/public_html/$THESITE
gzip /var/zpanel/hostdata/zadmin/public_html/$THESITE/backups/files/sitebackup_${THESITE}_${THEDA TE}.tar
find /var/zpanel/hostdata/zadmin/public_html/$THESITE/backups/files/site* -mtime +5 -exec rm {} ;
find /var/zpanel/hostdata/zadmin/public_html/$THESITE/backups/files/db* -mtime +5 -exec rm {} ;
我试图在ssh中运行它,看看它是否会输出数据,但我得到这个错误:
arudd@new-host-3:/var/zpanel/hostdata/zadmin/public_html/ic_sitescribersdev_com/backups$ sudo sh backup.sh
: not found2: backup.sh:
: not found8: backup.sh:
: Directory nonexistent_zadmin_ironcowboyar/zpanel/hostdata/zadmin/public_html/ic.sitescribersdev.com
'@'localhost' (using password: YES) when trying to connectwboy
: not found10: backup.sh:
tar: var/zpanel/hostdata/zadmin/public_html/ic.sitescribersdev.comrr: Cannot stat: No such file or directory
tar (child): /var/zpanel/hostdata/zadmin/public_html/ic.sitescribersdev.comr/backups/files/sitebackup_ic.sitescribersdev.comr_1107141435r.tar: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
: No such file or directoryc.sitescribersdev.com.sitescribersdev.com
: not found13: backup.sh:
find: missing argument to `-exec'
find: `/var/zpanel/hostdata/zadmin/public_html/ic.sitescribersdev.comr/backups/files/db*': No such file or directory
任何帮助我做错了这个工作将是非常棒的。
谢谢!
我想到了。 它抛出错误,因为脚本是在Windows中创建的。 我所要做的就是在脚本上安装并运行dos2unix,然后它就像一个魅力一样工作!
链接地址: http://www.djcxy.com/p/93595.html上一篇: Back Up Script for site and database showing error
下一篇: Mysqldump getting error only when trying to output to file