Web Hosting Forum | Lunarpages
News: July 14, 2008 - New Contest! - Submit Your WordPress Theme Designs, Win BIG!
June 30, 2008 - Submit Your Site for the July 08 Site of the Month Award!
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
July 26, 2008, 12:12:55 AM


Login with username, password and session length


Pages: 1 2 3 [4] 5 6 7   Go Down
  Print  
Author Topic: Site and MySQL backups via cron  (Read 30879 times)
JERRY JULIANO
Space Explorer
***
Offline Offline

Posts: 9


« Reply #45 on: July 22, 2005, 09:07:29 AM »

hi, thanks for the scripts! One question though, how do i know if they are working or not? I set up the job to send me a database (email) ever minute... i didn't get any error reports or anything though... anyway to tell other than sitting and waiting?

Logged
Danielle
Resident Alien
Administrator
Berserker Poster
*****
Offline Offline

Posts: 8877


nihil sunt omnia


WWW
« Reply #46 on: July 22, 2005, 10:11:22 AM »

Hi Jerry Juliano,

If you have it setup right, you should get an email for it, but you certainly should not set it up to email you every minute.  I will say that doing that will likely cause high load on your server or it to crash if you choose to backup your site each and every minute and have that emailed to you each and every minute...

Whenever possible, a cron job should not be setup more frequently than every 15 minutes, and a backup takes a great deal of processing power, so I wouldn't advise doing it during the day nor more than 1 time a day or every couple of days during the middle of the night (and testing the setup during the middle of the night or during the weekend when you are configuring it for the first time).

If you haven't received any email, then something is not working right, though, so providing what you have for the script and cron job with any password removed would help to see what's going on. Before you do that, however, please remove the cron job sending you an email every minute and change to a more reasonable timeframe or to a specific time each day once and only once to do the backup (like midnight).

Thanks.
« Last Edit: July 22, 2005, 10:16:15 AM by Danielle » Logged

Danielle Wallace
- nihil sunt omnia -
Lunarpages Webhosting ~ Lunarpages Forums ~ Lunarpages Affiliates
Administrator Training Manager - System Administrator Team


Ruby Asylum - For those crazy about Ruby
A&E Writing Forum ~ Best Garden ~ Endar & Endar Gallery ~ RatingBar.com

Every living creature on this earth dies alone.
rocketcitymath
Space Explorer
***
Offline Offline

Posts: 8


« Reply #47 on: September 17, 2005, 08:08:50 PM »

I am having some trouble getting these scripts to work; seems to be a filepath problem.

I tried using the full site backup file but I get the following error:
"Connected to ftp.domain.org, for user user_nameFTP upload has failed.
Warning: unlink(site-2005-09-17_19-59-25.gz): No such file or directory in /home/domain/public_html/crons/siteback.php on line 57"

Then, I tried using the database backup and while it works fine when I put
$filename= backup-$datestamp.sql.gz";
I receive the following error when I put
$filename= "/home/user_name/backup-$datestamp.sql.gz";

Connected to ftp.domain.org, for user user_name
Warning: ftp_put(): Rename/move failure: No such file or directory in /home/user_name/public_html/crons/database.php on line 41
FTP upload has failed.

The two errors seem kind of related, so I guess it's the same problem.

Can someone please help me? Thanks.
Logged
Danielle
Resident Alien
Administrator
Berserker Poster
*****
Offline Offline

Posts: 8877


nihil sunt omnia


WWW
« Reply #48 on: September 17, 2005, 08:55:32 PM »

Are you using user_name itself or are you replacing the values with your actual cPanel username and so on?  You have to change the information to fit your username, domain, etc.
Logged

Danielle Wallace
- nihil sunt omnia -
Lunarpages Webhosting ~ Lunarpages Forums ~ Lunarpages Affiliates
Administrator Training Manager - System Administrator Team


Ruby Asylum - For those crazy about Ruby
A&E Writing Forum ~ Best Garden ~ Endar & Endar Gallery ~ RatingBar.com

Every living creature on this earth dies alone.
rocketcitymath
Space Explorer
***
Offline Offline

Posts: 8


« Reply #49 on: September 17, 2005, 09:21:34 PM »

I am changing it to my actual usernames and so on.

I've replaced the settings to correspond with my domain, and the database backup will work if I specify nothing for the folder. But the site backup won't work, and I can't put the database backup in another folder.
« Last Edit: September 17, 2005, 09:24:46 PM by rocketcitymath » Logged
Danielle
Resident Alien
Administrator
Berserker Poster
*****
Offline Offline

Posts: 8877


nihil sunt omnia


WWW
« Reply #50 on: September 17, 2005, 10:44:14 PM »

The issue with it being a file path problem is that b/c you've replaced the values in your post with errors that aren't the actual errors, no-one can see if it really is a file path issue.  Is there any way we would be able to see the actual errors without having them replaced by other values?  If you wanted, you could PM them to me, but I really do need to see the real errors being returned and values.

Thanks.
Logged

Danielle Wallace
- nihil sunt omnia -
Lunarpages Webhosting ~ Lunarpages Forums ~ Lunarpages Affiliates
Administrator Training Manager - System Administrator Team


Ruby Asylum - For those crazy about Ruby
A&E Writing Forum ~ Best Garden ~ Endar & Endar Gallery ~ RatingBar.com

Every living creature on this earth dies alone.
valis
Trekkie
**
Offline Offline

Posts: 11



« Reply #51 on: November 10, 2005, 02:02:48 AM »

I’ve really come late to this party. :\ I’ve tried my best to read through everything, so if I repeat something, please forgive me.

The problem, as I understand it, is managing automated backup procedures for your MySQL database. I went through the whole business of writing code to be run on the host via cron, and then FTP the result to my home server. Your situation may be quite different, but here is what I did to resolve the problem to my satisfaction.

What I needed was a process to be run on a schedule that would backup my MySQL database onto a computer here at home. (It could be a computer anywhere, really.) I have a server running WinXP Professional, in this case. I downloaded and use a product called “ncron” to run on WinXP. (It was designed for NT.) I then wrote a script to run on a schedule. Locally, I maintain a MySQL server. It is not specifically required for what I need, but the utility “mysqldump” is.

I created a script that includes the following:

Code:
C:
cd C:\ . . . . \MySQL4\bin
mysqldump <database name> -h <database URL> -u <database userID> -c -e --add-drop-table --password=<database password> --compress --single-transaction --result-file=D:\hosts\. . . \mysql-backup\<mywebsitename>.sql
. . . (plus some gzip stuff)

Let’s call that script “backup.bat”. I then added an entry in the ncron schedule file such as:

Code:
#0 0,6,14,18,20 * * * c:\www\MySQL4\bin\backup.bat

The cron job is then run at the prescribed hours and runs the mysqldump program. It connects to Lunarpages MySQL server and runs the backup query. The compressed result is received by my server, then stored and compressed with gzip.

For this to work you must take care to insure that your home (or other) server’s address is listed on the CPanel page for MySQL Databases / Access Hosts. If set up correctly, your home server (or desktop for that matter) will connect to Lunarpages, run a backup query on your MySQL database, and store a copy safely on your computer.
Logged

There is no Sanity without a Playful Imagination
Amuro Hajime
Newbie
*
Offline Offline

Posts: 4


« Reply #52 on: November 29, 2005, 07:33:07 AM »

I seem to be running into some weird errors with this script.  I set all the variables, uploaded the script and then I haven't been able to get any further.  I have tested the script with both cron and in a web browser.  The first errors I ran into were T_STRING errors that were fixed by removing any comments that came after a line of code.  Now I am getting T_ECHO errors in the "check connection" if/else statement.  First I tried to comment out the echo's in the "if" but then it just gave me another error for the line the "exit" statement is on.

Anyone have an idea as to what is causing all these problems?  I shouldn't have to remove so any comments and functions to get this to work it all looks pretty standard.
Logged
TeraHz
Spaceship Captain
*****
Offline Offline

Posts: 100


WWW
« Reply #53 on: November 29, 2005, 10:55:47 AM »

http://www.lunarforums.com/forum/index.php?topic=29249.0 -> here is a script that will allow you to ftp or scp your home directory to wherever you want, from wherever you want. I'm using it so far without a problem.

It will also backup your databases and your emails by the way. It is a complete backup of your account on lunarpages.
« Last Edit: November 30, 2005, 05:37:25 PM by TeraHz » Logged

-
?? Huh ?? HuhHuh??!
scanman20
Master Jedi
*****
Offline Offline

Posts: 1199



WWW
« Reply #54 on: November 29, 2005, 12:58:37 PM »

I seem to be running into some weird errors with this script. I set all the variables, uploaded the script and then I haven't been able to get any further. I have tested the script with both cron and in a web browser. The first errors I ran into were T_STRING errors that were fixed by removing any comments that came after a line of code. Now I am getting T_ECHO errors in the "check connection" if/else statement. First I tried to comment out the echo's in the "if" but then it just gave me another error for the line the "exit" statement is on.

Anyone have an idea as to what is causing all these problems? I shouldn't have to remove so any comments and functions to get this to work it all looks pretty standard.
Odds are that you have a syntax error when you made a change. Probably something simple like an extra (or missing) quote or semicolon. I wrote this script years ago and it still runs fine on my servers every day.
Logged

Even a broken clock is right twice a day.
NotOneBit.com
MCSE - MCSA - MCP
Amuro Hajime
Newbie
*
Offline Offline

Posts: 4


« Reply #55 on: November 29, 2005, 04:31:20 PM »

I can't imagine it is a missing quotes (or something like that) cause I get an error at line 2 when all I have done is copied the code from this forum post, saved the file, and uploaded it to the server (haven't even changed the variables).  Then I remove the comments after the line with the date function and the error goes away showing a new error at line 5 (which has comments after it too).  I work my way all the way down the file getting error after error cleaned up until I have no more lines with comments after them.  That is when at line 31 it starts telling me I have "T_ECHO" errors.  This is where I am stuck.
Logged
scanman20
Master Jedi
*****
Offline Offline

Posts: 1199



WWW
« Reply #56 on: November 29, 2005, 05:12:36 PM »

Well if you want to send me your logon info I'll check it out on your server myself.
Logged

Even a broken clock is right twice a day.
NotOneBit.com
MCSE - MCSA - MCP
twisty
Newbie
*
Offline Offline

Posts: 4


« Reply #57 on: December 08, 2005, 08:32:45 PM »


Re: The "MySQL backup via cron - Emailed to You" script

Small correction needed here:

This...

Code:
$content.= "Content-Type: Application/Octet-Stream; name=\"$attachmentname\"\r\n";

Should instead be...

Code:
$content.= "Content-Type: application/x-gzip; name=\"$attachmentname\"\r\n";

Or else the email attachment won't be a real .gz file  Thumbs Up
Logged
scanman20
Master Jedi
*****
Offline Offline

Posts: 1199



WWW
« Reply #58 on: December 09, 2005, 09:34:05 PM »

Funny I've never had a problem opening it.
Logged

Even a broken clock is right twice a day.
NotOneBit.com
MCSE - MCSA - MCP
twisty
Newbie
*
Offline Offline

Posts: 4


« Reply #59 on: December 10, 2005, 12:54:38 PM »

Funny I've never had a problem opening it.

Hi scanman,

application/octet-stream is considered an 'ambiguous' MIME type and a .gz file won't be downloaded correctly from some of the POP3 email services (it's hit and miss, thus it will work ok for some but not all).

application/x-gzip OTOH, is considered a 'specific' MIME type and is the correct one to use for .gz files.

http://www.w3schools.com/media/media_mimeref.asp

 Cool
Logged
Pages: 1 2 3 [4] 5 6 7   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM