|
|
#1 |
![]() Join Date: Feb 2004
Location: Singapore
Posts: 26
![]() |
I have released a program to automate the backup of the Mambo MySQL database and send the backup data to an offsite destination for safe storage through email. See the program at http://mamboforge.net/projects/cron-backup/.
Welcome all to share their experiences on using Cron Jobs to automate their tasks. Creative use of cron may open up new possibilities through automation. |
|
|
|
|
|
#2 |
![]() Join Date: Feb 2004
Location: Singapore
Posts: 26
![]() |
See here for more info on Cron backup:
http://forum.mamboserver.com/showthread.php?t=52559 I am working on a version that does not need to use the Linux "mutt" command to send out the emai, as some of the web host servers do not install this. |
|
|
|
|
|
#3 |
![]() Join Date: Oct 2004
Location: Athens, Greece
Posts: 40
![]() |
Hi,
I am getting the following error mail message: /bin/sh: /home/xxxxxxxx/etc/cron_backup.sh: /bin/sh : bad interpreter: No such file or directory Any ideas? |
|
|
|
|
|
#4 |
![]() Join Date: Feb 2004
Location: Singapore
Posts: 26
![]() |
Hi,
Is your server using C shell (csh) or Bourne shell (sh is the standard UNIX-system command interpreter)? Try replacing the first line: #!/bin/sh with #!/bin/csh did that work? Please see setup steps and diagrams at http://www.matrix-e.com/content/view/44/64/ Some of my servers use C shell, but generally, the rest of the commands are the same. |
|
|
|
|
|
#5 |
![]() Join Date: Oct 2004
Location: Athens, Greece
Posts: 40
![]() |
Thank you for the reply.
Unfortunately it does not work. ![]() |
|
|
|
|
|
#6 |
![]() Join Date: Feb 2004
Location: Singapore
Posts: 26
![]() |
What was the new error message?
Other than the common Shells sh and csh, there are other Shells such as ksh, bsh, tsh, ... |
|
|
|
|
|
#7 |
|
Join Date: Jan 2004
Posts: 15
![]() |
Got the same error as Macman with all the options you gave:
/bin/sh: /home/xxxx/etc/cron_backup.sh: /bin/ksh : bad interpreter: No such file or directory It looks promising to me! |
|
|
|
|
|
#8 |
![]() Join Date: Feb 2004
Location: Singapore
Posts: 26
![]() |
macman and locutuz,
Change the first line to: #!/bin/bash |
|
|
|
|
|
#9 |
![]() Join Date: Jul 2005
Posts: 21
![]() |
looks great derricklo! Changing to bash worked for me. The MySql file is empty, but I think I might not have the DB pwd correct. Image folder is sent fine.
|
|
|
|
|
|
#10 |
|
Join Date: Jan 2004
Posts: 15
![]() |
Bash worked neither...
/bin/sh: line 1: /home/xxx/ect/cron_backup.sh: No such file or directory Looks like I have the wrong path, but I checked it twice!? |
|
|
|
|
|
#11 |
![]() Join Date: Feb 2004
Location: Singapore
Posts: 26
![]() |
One fast way to check your DB password is to see your Mambo configuration.php file, all the info you need is in there.
At your Cron Jobs, the path should be /home/xxx/etc/cron_backup.sh instead of /home/xxx/ect/cron_backup.sh Hope this helps! |
|
|
|
|
|
#12 |
|
Join Date: Jan 2004
Posts: 15
![]() |
Whoops, typed it wrong. I tried it with bash; no luck (same error). Tried to put the file in the dir cgi-bin and again it didn't work.
|
|
|
|
|
|
#13 |
![]() Join Date: Feb 2004
Location: Singapore
Posts: 26
![]() |
Hi locutuz,
At Cron Jobs, create a new entry: “which php > /home/{yoursite}/etc/output.txt” for “* * * * *” After 1 minute, check file /home/{yoursite}/etc/output.txt. Since your php service is running, you should see: /usr/bin/php Replace the Cron entry by: “which bash > /home/{yoursite}/etc/output.txt” You should expect to see: /bin/bash If you do not see this path, you will need to ask your web host administrator to setup the path properly for you. Remember to delete the Cron entry and output.txt file after testing! |
|
|
|
|
|
#14 |
|
Join Date: Jan 2004
Posts: 15
![]() |
Derrick, Thanks for your effort in this, but I stop touching the cron tab for now. I have got a very angry hoster by now beacause of beavy traffic. Guess something got into a loop
|
|
|
|
|
|
#15 |
![]() Join Date: Aug 2005
Posts: 1
![]() |
/bin/sh: /home/xxxxf/etc/cron_backup.sh: Permission denied
What does this mean? EDIT: I figured out that problem, I had set the Cron up with the wrong directory. I did however get another error: Code:
/home/xxxx/etc/cron_backup.sh: line 80: mutt: command not found /home/xxxx/etc/cron_backup.sh: line 83: mutt: command not found |
|
|
|
|
|
#16 |
![]() Join Date: Feb 2004
Location: Singapore
Posts: 26
![]() |
Yep, looks like "mutt" is not installed on your server. I will try to release a version that does not require "mutt" in the next few days.
As a test, change the first line to: #!/bin/bash Bash may have mutt installed, although unlikely. |
|
|
|
|
|
#17 |
![]() Join Date: Jul 2005
Posts: 21
![]() |
Hi derricklo, I'm not sure if you're still around these forums but this was working fine for me for a while and now all I get is the mySql backup. My images directory is around 20MB, so is there a size limit for mutt or that my host would have for attatchments. I am using gmail, so I don't think they reject attachments... or do they?
-Thanks
__________________
Watch me get banned for sharing my opinion! Seriously, if you want help from the developers, check out OpenSourceMatters |
|
|
|
|
|
#18 |
![]() Join Date: Feb 2004
Location: Singapore
Posts: 26
![]() |
Hi,
Such a large email file attachment maybe pushing it a bit. I have 3 suggestions: 1) See the date and time of the Files.tar.gz file using FTP. Download it directly to your PC using FTP. Is the file created correctly? Can the files and dirs can be uncompressed properly on your local drive? tar problem or mutt problem? 2) Setup more filenames, tar, and mutt statements to break up the image dir into several sub-dirs. E.g. WWWDIR1=./public_html/images/banners E.g. WWWDIR2=./public_html/images/stories tar and mutt these smaller files. 3) Usually, we do not need to backup the images/files daily, only daily backup for MySQL DB. Consider backing up images/files only once a week? Good luck! |
|
|
|
|
|
#19 |
![]() Join Date: Jul 2005
Posts: 21
![]() |
Thank you very much for the suggestions.
The date and time are recent, so I know it is creating the files. I'm not really sure how I could check if the email was sent or not. Don't know much (alright, anything) about mutt. The only thing about FTPing them to my computer is I have a very slow connection so I usually download the attachment from work. The computers are so locked down there that I can't even get into cPanel, let alone use FTP, so I found it easier to download the email attachment. My problem with the different directories is that I use zOOm and it creates random dirs for the pictures so I wouldn't know which new ones to add in the script. You're right that the directory does not need to be backed up so often. I could make two crons and edit them so one only does images less regularly than the one doing the db. Thanks for your help again.
__________________
Watch me get banned for sharing my opinion! Seriously, if you want help from the developers, check out OpenSourceMatters |
|
|
|
|
|
#20 | |
![]() Join Date: Aug 2004
Posts: 15
![]() |
Quote:
http://home.clara.net/dwotton/unix/mail_files.txt It uses sendmail but allows you to add attachments. Save the file above in /home/{yoursite}/etc/ as mail_files.sh and chmod it 700. Instead of using mutt, you can use the mail_files.sh command after the mysqldump and zip commands to email the zipped files. Code:
if [ -f $STATUS ]; then
date >> $STATUS
echo "Already completed cron job. Please manually delete $STATUS to reset for testing."
else
date >> $STATUS
MySQLFILE=$ETCDIR/MySQL.sql.gz
BACKUPFILE=$ETCDIR/Files.tar.gz
mysqldump --opt --quote-names -u $DBUSER -p$DBPASS $DBNAME | gzip > $MySQLFILE
tar -zcf $BACKUPFILE $WWWDIR
$ETCDIR/mail_files.sh -t $EMAIL -s "Weekly Joomla Backup" -b "$MySQLFILE $BACKUPFILE" \ < /dev/null
#FOR TESTING:
#Program will run within the next minute and will set the status.txt flag.
#It will only run again when you manually delete the status.txt file.
#Set cron schedule to "* * * * *" and comment the following line.
rm $STATUS
fi
|
|
|
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| bigAPE Site Backup Component v1.0 Released | bigAPE | Components | 28 | January 21st, 2008 08:49 |
| Cron job for daily backup | guider | Administration Questions | 19 | July 28th, 2006 09:21 |
| bigAPE Site Backup Component v1.1 Released | bigAPE | Components | 29 | February 18th, 2006 22:36 |
| OT: Cron backup jobs i cPanel | stanley | Danish Forum | 0 | March 4th, 2005 00:41 |
| automated email account registration Ensim | darien | Open Source Products for Mambo | 3 | November 29th, 2004 20:31 |