Web Hosting Forum | Lunarpages
News: July 14, 2008 - New Contest! - Submit Your WordPress Theme Designs, Win BIG!
August 25, 2008 - Time to Vote for the August 2008 Site of the Month!
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
August 30, 2008, 05:56:55 AM


Login with username, password and session length


Pages: 1 ... 3 4 [5] 6 7   Go Down
  Print  
Author Topic: Site and MySQL backups via cron  (Read 31567 times)
scanman20
Master Jedi
*****
Offline Offline

Posts: 1225



WWW
« Reply #60 on: December 10, 2005, 07:10:15 PM »

So noted.
Logged

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

Posts: 4


« Reply #61 on: December 11, 2005, 01:44:18 AM »

Btw I would like to commend you on these scripts. Why? Not because they are overly complex but rather because they are lean and efficient. I do some PHP coding myself and had a look around to see what was available out there to save me the time of having to do it from scratch.

Well I was appalled at some of what I saw. Overly bloated and involved scripts that were not user friendly at all. Some didn't even work correctly with typical server configs.

I'm currently using your emailed backups one and have my databases sent nightly via cron to both gawab.com (2 gig inbox) and 30gigs.com (30 gig inbox).

And while I'm here, I'll also mention that I found a nice script for restoring large mysql dumps (ones too large to do at once because of timeouts)...

http://www.ozerov.de/bigdump.php

So between these two, that pretty much takes care of both sides of the equation as far as database backups go  Thumbs Up
Logged
ndboost
Newbie
*
Offline Offline

Posts: 1


« Reply #62 on: December 15, 2005, 10:36:59 AM »

ok here goes nothing, as a few others have said ive read to alot of these posts to try and narrow my problem down.

it seems that when trying to dump the sql statements to my server it creates the file but leaves it empty.

Here is the mysqldump code:

Quote
$datestamp = date("Y-m-d");      // Current date to append to filename of backup file in format of YYYY-MM-DD

/* CONFIGURE THE FOLLOWING THREE VARIABLES TO MATCH YOUR SETUP */
$dbuser = "azscf";      // Database username
$dbpwd = "*****";         // Database password
$dbname = "azsc_forum";      // Database name. Use --all-databases if you have more than one
$filename= "/home/azsupras/azsupracentral.com/crons/backup.sql";   // The name (and optionally path) of the dump file
$dbhost = 'azscf.azsupracentral.com';
$command = "mysqldump --opt -c -e -Q -u $dbuser -p'$dbpass' -h'$dbhost' $dbname > $filename";
$result = passthru($command);
now obviously i have modified the orgional code a bit, to instead of gzipping the sql statement to leave it in .sql format.

on another note, im hosted through dreamhost and i dont use cpanel. But all the login details are correct and as far as i can tell the $filename is correct. safe mode is disabled, anyone got any ideas?
« Last Edit: December 15, 2005, 10:38:34 AM by ndboost » Logged
twisty
Newbie
*
Offline Offline

Posts: 4


« Reply #63 on: December 16, 2005, 12:51:37 PM »

ndboost,

You'll need to make sure that you specify an access host in the MySQL section of the control panel where your database(s) are currently stored...
 
ie. azscf.azsupracentral.com

The IP# to list there will be that of the other account you're trying to run the scripts from.

I hope this helps.
Logged
ASFx
Space Explorer
***
Offline Offline

Posts: 6


« Reply #64 on: January 04, 2006, 09:17:29 PM »

The database for my forum is almost 1GB in size, and this script just seems to timeout in my browser whenever i try to run it.  Does anyone have suggestions on how to get this to work with a large database, or any other scripts that will just automatically backup my database locally or to a remote ftp daily?

Thanks.
Logged
carastas
Newbie
*
Offline Offline

Posts: 1


« Reply #65 on: January 05, 2006, 06:57:50 AM »

you can try using sitevault (www.site-vault.com) it works very well for me, but my sites are alot smaller than that, the good thing is that it does incremental site and mysql backup, although i think the mysql is not incremental, it just downloads everything over and over again, never timed out, it uses some php files it uploads on the server to act as a gateway to mysql.

the bad thing is that it has to run on a windows machine and that it doesn't have scheduling... i requested for it on their site and they said it should be done "at the beginning of january" do who knows...
Logged
TeraHz
Spaceship Captain
*****
Offline Offline

Posts: 100


WWW
« Reply #66 on: March 23, 2006, 04:26:12 PM »

...
 or any other scripts that will just automatically backup my database locally or to a remote ftp daily?
...
I use this:
http://joro.geodar.com/diary/2005/11/11/233
Logged

-
?? Huh ?? HuhHuh??!
windydays
Newbie
*
Offline Offline

Posts: 2


« Reply #67 on: March 26, 2006, 09:58:50 PM »

I used the php at the top of this thread to build cron jobs for both full account backups and mySQL backups, and now I can rest in peace. Thank you to scanman for giving us a great start. Be warned though that at least on the sinope server, there was considerable knashing and grinding of teeth, mostly with getting paths correct because php was already throwing in the full server path to my account. Also, for those wondering how to test php without waiting for cron, I debugged below public_html using a reduced tar target focused on a single minor subdirectory, and once operating, moved the pgm up above public_html - and then did a few final debug runs using short-interval crons. php messages provided in email were more meaningful than the silly returns in the error file, and as usual when debugging from the browser, full php error messages and debug tracks can be written to the browser window, making error fixes easier to handle. In the process, I did lose track of where several cron jobs were depositing tar files, and an out-of-disk-space error was thrown once, though it did not show in cPanel.

Meanwhile - I've noted that output tar file sizes are about 10% smaller than with backup used in cPanel. Anyone seen this before? I have not yet downloaded the output gzips located in a very far away place, for the purpose of comparisons, but I am wondering if this is due to differences in compression, or, am I missing some directories by doing backups this way? I suppose the mySQL size difference is somewhat alarming, more so than the account backups...

-Bill
Logged
Cook
Space Explorer
***
Offline Offline

Posts: 9



« Reply #68 on: April 04, 2006, 12:10:11 AM »

Regular MySQL backups are a must, everybody will agree to that. Typically you would backup once a day and store the precious backup file on another computer for use if and when the disaster strikes.

All is fine.

Really? Just wondering: say a backup is made at 12midnight, and at 12noon, the server crashes. What about the 12 hours of data lost? Does LP restore the binary logs for us? If so, in how much time? If not, how can we do it ourselves? Do we have access at all to the server's binary logs?

Anyone?
Logged

Cook
stevedave
Trekkie
**
Offline Offline

Posts: 13


« Reply #69 on: April 06, 2006, 04:14:55 PM »

I am trying to implement the site backup with FTP.  My cron job is called SiteBackup.php and is located at the following:

/home/<useraccount>/public_html/CronJobs/SiteBackup.php

I execute it using:

php -q /home/<useraccount>/public_html/CronJobs/SiteBackup.php

I am able to get connected to my FTP, however I get the following error:

<b>Warning</b>:  ftp_put(): The command 'STOR' is disabled. in <b>/home/<useraccount>/public_html/CronJobs/SiteBackup.php</b> on line <b>41</b><br />
FTP upload has failed.

I have seen the STOR error before when trying to FTP to my FTP server.  However, this should not be an issue.  On my FTP server, I have a folder:

/SalesBackups

As long as I point inside that directory, I have STOR capabilities.  I know this because I can manually backup using FTP from the control panel.

I think my confusion is coming from the $filenames at the top.  Can someone point me in the right direction as to what these should be?

I need my destination filename to be: "/SalesBackup/" . $filename

At least I thought...I don't understand why there are two $filename variables at the top.
Logged
stevedave
Trekkie
**
Offline Offline

Posts: 13


« Reply #70 on: April 12, 2006, 04:06:54 AM »

I guess my message above wasn't clear.
Logged
GMTurner
Berserker Poster
*****
Offline Offline

Posts: 7539



WWW
« Reply #71 on: April 12, 2006, 08:31:26 PM »

The first $filename is the name of the file as you want it to appear when stored. The second $filename specifies the path and adds that to the beginning of the first $filename...
Logged

The above post was made at a time when I gave a dang and doesn't necessarily reflect my current views or opinions.

For those no longer with us ... Grr..!!

The Redheaded Penguin
stevedave
Trekkie
**
Offline Offline

Posts: 13


« Reply #72 on: April 14, 2006, 08:10:31 AM »

I have continued to fiddle with this and work out some problems I was having.  First of all, here is my top part where I set my variables:

$filename= "Shultz_Backup-$datestamp.tar";   // The name (and optionally path) of the dump file
$ftp_server = "Huh";      // Name or IP. Shouldn't have any trailing slashes and shouldn't be prefixed with ftp://
$ftp_port = "21";   // FTP port - blank defaults to port 21
$ftp_username = "Huh";      // FTP account username
$ftp_password = "Huh";      // FTP account password - blank for anonymous
$filename = "/home/<myaccount>/" . $filename . ".gz";

$command = "tar cvf $filename ~/*";
$result = exec($command);

$command = "gzip -9 -S .gz $filename";
$result = exec($command);

For the tar and gzip commands, I had to remove the ~/ in front because if not, it did not build my path correctly and then it would not create the file.  So once I figured this out, I can see it creating my backup file on my server and it also unlinks at the end properly.

However, I am having problems FTPing.  In the email I get, it says FTP connection to the server was successful.

If I run the ftp_put() command like the following:

$upload = ftp_put($ftp_conn, $filename, "/SalesBackup/backup.tar.gz", FTP_BINARY);

It just says "Upload Failed", no errors or warnings

If I run ftp_put command like the following:

$upload = ftp_put($ftp_conn, "/SalesBackup/backup.tar.gz", $filename, FTP_BINARY);

It makes a comment about the STOR command not working for /home/<myaccount>/Shultz_Backup-<date>.tar.gz... --> It seems that it is trying to FTP to the directory as designated on the lunarpages server, not as my FTP server.

The other thing as you can see above is that on my FTP server, when you FTP in, you then need to drill into a directory and then place the file.  The directory name is SalesBackups.  Do I need to do /SalesBackups/... or SalesBackups/...?
Logged
orion7_11
Newbie
*
Offline Offline

Posts: 1


« Reply #73 on: August 31, 2006, 01:01:40 PM »

do these scripts have to be saved and executed in the public_html folder? I would rather keep them in the main directory.

home/<acct_name>/phpscript.php
Logged
Nibbler
21st century digital boy
Master Jedi
*****
Offline Offline

Posts: 1178



WWW
« Reply #74 on: August 31, 2006, 01:15:52 PM »

That should be fine. Just make sure your paths are correct.
Logged

Missing since 1983

Pages: 1 ... 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