MDN

Go Back   Mambo - Forums Closed for posting > Mambo 3rd Party Addons > Open Source Products for Mambo

Reply
 
Thread Tools Search this Thread Display Modes
Old August 1st, 2005, 23:33   #1
derricklo
 
Join Date: Feb 2004
Location: Singapore
Posts: 26
derricklo is on a distinguished road
Smile Automated cron backup thru email

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.
__________________
Best Regards,
Derrick
http://www.matrix-e.com
http://www.5ver.com
derricklo is offline   Reply With Quote
Old August 4th, 2005, 00:35   #2
derricklo
 
Join Date: Feb 2004
Location: Singapore
Posts: 26
derricklo is on a distinguished road
Smile MySQL daily cron job backup thru email

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.
__________________
Best Regards,
Derrick
http://www.matrix-e.com
http://www.5ver.com
derricklo is offline   Reply With Quote
Old August 8th, 2005, 10:32   #3
macman
 
Join Date: Oct 2004
Location: Athens, Greece
Posts: 40
macman is on a distinguished road
Default

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?
__________________
--
Aris Ntatsis - Open Source Solutions in Greece
http://onscreen.gr
macman is offline   Reply With Quote
Old August 8th, 2005, 20:46   #4
derricklo
 
Join Date: Feb 2004
Location: Singapore
Posts: 26
derricklo is on a distinguished road
Default sh or csh?

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.
__________________
Best Regards,
Derrick
http://www.matrix-e.com
http://www.5ver.com
derricklo is offline   Reply With Quote
Old August 9th, 2005, 01:55   #5
macman
 
Join Date: Oct 2004
Location: Athens, Greece
Posts: 40
macman is on a distinguished road
Default

Thank you for the reply.

Unfortunately it does not work.

__________________
--
Aris Ntatsis - Open Source Solutions in Greece
http://onscreen.gr
macman is offline   Reply With Quote
Old August 9th, 2005, 20:08   #6
derricklo
 
Join Date: Feb 2004
Location: Singapore
Posts: 26
derricklo is on a distinguished road
Default

What was the new error message?

Other than the common Shells sh and csh, there are other Shells such as ksh, bsh, tsh, ...
__________________
Best Regards,
Derrick
http://www.matrix-e.com
http://www.5ver.com
derricklo is offline   Reply With Quote
Old August 11th, 2005, 09:48   #7
locutuz
 
Join Date: Jan 2004
Posts: 15
locutuz is on a distinguished road
Default

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!
locutuz is offline   Reply With Quote
Old August 11th, 2005, 13:05   #8
derricklo
 
Join Date: Feb 2004
Location: Singapore
Posts: 26
derricklo is on a distinguished road
Default

macman and locutuz,

Change the first line to:
#!/bin/bash
__________________
Best Regards,
Derrick
http://www.matrix-e.com
http://www.5ver.com
derricklo is offline   Reply With Quote
Old August 11th, 2005, 21:46   #9
focalguy
 
Join Date: Jul 2005
Posts: 21
focalguy is on a distinguished road
Default

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.
focalguy is offline   Reply With Quote
Old August 12th, 2005, 00:46   #10
locutuz
 
Join Date: Jan 2004
Posts: 15
locutuz is on a distinguished road
Default

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!?
locutuz is offline   Reply With Quote
Old August 12th, 2005, 03:17   #11
derricklo
 
Join Date: Feb 2004
Location: Singapore
Posts: 26
derricklo is on a distinguished road
Default

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!
__________________
Best Regards,
Derrick
http://www.matrix-e.com
http://www.5ver.com
derricklo is offline   Reply With Quote
Old August 12th, 2005, 03:49   #12
locutuz
 
Join Date: Jan 2004
Posts: 15
locutuz is on a distinguished road
Default

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.
locutuz is offline   Reply With Quote
Old August 14th, 2005, 02:14   #13
derricklo
 
Join Date: Feb 2004
Location: Singapore
Posts: 26
derricklo is on a distinguished road
Default Path test

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!
__________________
Best Regards,
Derrick
http://www.matrix-e.com
http://www.5ver.com
derricklo is offline   Reply With Quote
Old August 15th, 2005, 06:28   #14
locutuz
 
Join Date: Jan 2004
Posts: 15
locutuz is on a distinguished road
Default

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
locutuz is offline   Reply With Quote
Old August 15th, 2005, 22:10   #15
cloud1494
 
Join Date: Aug 2005
Posts: 1
cloud1494 is on a distinguished road
Default

/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
That pretty much means that the server doesn't have mutt installed right?
cloud1494 is offline   Reply With Quote
Old August 16th, 2005, 22:22   #16
derricklo
 
Join Date: Feb 2004
Location: Singapore
Posts: 26
derricklo is on a distinguished road
Default

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.
__________________
Best Regards,
Derrick
http://www.matrix-e.com
http://www.5ver.com
derricklo is offline   Reply With Quote
Old September 11th, 2005, 10:15   #17
focalguy
 
Join Date: Jul 2005
Posts: 21
focalguy is on a distinguished road
Default

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
focalguy is offline   Reply With Quote
Old September 12th, 2005, 00:33   #18
derricklo
 
Join Date: Feb 2004
Location: Singapore
Posts: 26
derricklo is on a distinguished road
Default

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!
__________________
Best Regards,
Derrick
http://www.matrix-e.com
http://www.5ver.com
derricklo is offline   Reply With Quote
Old September 12th, 2005, 20:48   #19
focalguy
 
Join Date: Jul 2005
Posts: 21
focalguy is on a distinguished road
Default

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
focalguy is offline   Reply With Quote
Old September 22nd, 2005, 13:43   #20
brianilland
 
Join Date: Aug 2004
Posts: 15
brianilland is on a distinguished road
Default

Quote:
Originally Posted by derricklo
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.
If you don't have Mutt, you could use this script :

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
Works for me. My backups were all hardcoded. Thanks for the more elegant script with variables.
brianilland is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

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


All times are GMT -7. The time now is 07:45.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.