Back Up Script for site and database showing error

I am no expert at this, but I wanted to created a script that I could turn into a cron job to run a backup of the websites and database on my home server. I found this script and customized it to my settings:

#!/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 {} ;

I tried to run it in ssh to see if it would output the data but I get this error:

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

Any help on what I am doing wrong to get this to work would be awesome.

Thanks!


I figured it out. It was throwing out errors because the script was made in windows. All I had to do was install and run dos2unix on the script and then it worked like a charm!

链接地址: http://www.djcxy.com/p/93596.html

上一篇: 备份数据库时出错

下一篇: 为站点和数据库备份脚本显示错误