Go Back   HostGator Peer Support Forums > Public Forums > Pre-Sales Questions

Notices

Reply
 
Thread Tools
  #1  
Old 06-21-2007, 04:47 PM
php_dev php_dev is offline
Hatchling Croc
 
Join Date: May 2007
Posts: 19
Default Help

Hi all,
today i have deleted a table of my db . Do Hostgator have a copy of backup?
Reply With Quote
  #2  
Old 06-21-2007, 04:51 PM
GatorJay
HostGator Guest
 
Posts: n/a
Default Re: Help

Quote:
Originally Posted by php_dev View Post
Hi all,
today i have deleted a table of my db . Do Hostgator have a copy of backup?
Depending on how recent the database was created, we may have a backup. Likely it would be from last weekend.

Just fill out the restore form at www.hostgator.com/restore.php
Reply With Quote
  #3  
Old 06-21-2007, 05:09 PM
Impavidus Impavidus is offline
Junior Croc
 
Join Date: Feb 2006
Posts: 155
Default Re: Help

Hi php_dev,

Why aren't you doing regular backups?

Reply With Quote
  #4  
Old 06-21-2007, 05:12 PM
php_dev php_dev is offline
Hatchling Croc
 
Join Date: May 2007
Posts: 19
Default Re: Help

Thank you for the fast reply. I have just filled the form and now i hope for the backup (47000 rows).
Reply With Quote
  #5  
Old 06-21-2007, 05:13 PM
esl's Avatar
esl esl is offline
Emperor Croc
 
Join Date: Jan 2005
Location: Proud to be an American - USA
Posts: 2,227
Default Re: Help

Hello php_dev,
Quote:
Originally Posted by Impavidus View Post
Hi php_dev,

Why aren't you doing regular backups?

He/she may be. There could have been numerous amounts of changes within the last 24 hours.
__________________
Have a great day,
Evan
Reply With Quote
  #6  
Old 06-21-2007, 05:17 PM
php_dev php_dev is offline
Hatchling Croc
 
Join Date: May 2007
Posts: 19
Default Re: Help

Quote:
Originally Posted by Impavidus View Post
Hi php_dev,

Why aren't you doing regular backups?

Hi Impavidus,
my db is more than 90mb and i don't have adsl but a connection with a gps (190kbs). From today i will doing regular backups every 2 days.
Reply With Quote
  #7  
Old 06-21-2007, 05:19 PM
slapshotw's Avatar
slapshotw slapshotw is offline
Veteran Croc
 
Join Date: Jun 2006
Posts: 5,164
Default Re: Help

You can get a different account to send the backups to..when I was a reseller I used a dreamhost plan ($20 for the first year) to store backups.
__________________
Follow me on Twitter! http://twitter.com/mrw
Reply With Quote
  #8  
Old 06-21-2007, 05:29 PM
esl's Avatar
esl esl is offline
Emperor Croc
 
Join Date: Jan 2005
Location: Proud to be an American - USA
Posts: 2,227
Default Re: Help

Hello php_dev,
Please see:

http://forums.hostgator.com/showthread.php?t=18501
http://forums.hostgator.com/showthread.php?t=12786
http://forums.hostgator.com/showthread.php?t=17075
__________________
Have a great day,
Evan
Reply With Quote
  #9  
Old 06-21-2007, 05:52 PM
php_dev php_dev is offline
Hatchling Croc
 
Join Date: May 2007
Posts: 19
Default Re: Help

Hi esl Very useful your tips! With a cronjob i can backup big tables on my db in the night. What is the cron string to a file? For example: i write a script for backup my db a named it backup.php. What is the string for the cron to start this file every night to midnight?
Reply With Quote
  #10  
Old 06-21-2007, 05:56 PM
php_dev php_dev is offline
Hatchling Croc
 
Join Date: May 2007
Posts: 19
Default Re: Help

i have see a rsync example but i want to be able to set the time to start the file.

Last edited by php_dev; 06-21-2007 at 05:58 PM.
Reply With Quote
  #11  
Old 06-21-2007, 05:57 PM
esl's Avatar
esl esl is offline
Emperor Croc
 
Join Date: Jan 2005
Location: Proud to be an American - USA
Posts: 2,227
Default Re: Help

Hello php_dev,
Cron jobs aren't my thing.. but check out these threads.

http://forums.hostgator.com/showthread.php?t=18338
http://forums.hostgator.com/showthread.php?t=14628
__________________
Have a great day,
Evan
Reply With Quote
  #12  
Old 06-21-2007, 06:07 PM
Impavidus Impavidus is offline
Junior Croc
 
Join Date: Feb 2006
Posts: 155
Default Re: Help

Min Hour Day Month WeekDay Command
0 0 * * * php /home/username/backup.php

You can use cpanel's Cron Manager to create a job and run this command:

php /home/username/backup.php

I am using perl mysql backup script for our backups, but I create a php verison which creates backups to the localhost or to a remote server. I can look for it if you want.
Reply With Quote
  #13  
Old 06-21-2007, 06:13 PM
slapshotw's Avatar
slapshotw slapshotw is offline
Veteran Croc
 
Join Date: Jun 2006
Posts: 5,164
Default Re: Help

Use rsync with the cron...you'll save a LOT of resources and bandwidth.
__________________
Follow me on Twitter! http://twitter.com/mrw
Reply With Quote
  #14  
Old 06-21-2007, 06:14 PM
php_dev php_dev is offline
Hatchling Croc
 
Join Date: May 2007
Posts: 19
Default Re: Help

Quote:
Originally Posted by Impavidus View Post
Min Hour Day Month WeekDay Command
0 0 * * * php /home/username/backup.php

You can use cpanel's Cron Manager to create a job and run this command:

php /home/username/backup.php

I am using perl mysql backup script for our backups, but I create a php verison which creates backups to the localhost or to a remote server. I can look for it if you want.
YES .Look for it! i am afraid to manage cronjob (i don't want to do another mistake).
0 0 * * * php /home/username/backup.php.
The asterisks are for the day,month and weekday.
And so the string should be:
0 0 22 6 * php /home/username/backup.php
to start the cronjob to midnight of 22 June.It is true?
Reply With Quote
  #15  
Old 06-21-2007, 06:17 PM
php_dev php_dev is offline
Hatchling Croc
 
Join Date: May 2007
Posts: 19
Default Re: Help

Quote:
Originally Posted by slapshotw View Post
Use rsync with the cron...you'll save a LOT of resources and bandwidth.
Hi slapshotw,
i have already seen your example on another post about rsync but i don't know how to manage linux and so i don't know the differences for rsync and sync. But my db is really big and so if rsync can save resources can you explain me about it?
Reply With Quote
  #16  
Old 06-21-2007, 06:20 PM
php_dev php_dev is offline
Hatchling Croc
 
Join Date: May 2007
Posts: 19
Default Re: Help

Hi GatorJay,
Google is spidering my site just now.... how many time for the backup?
Reply With Quote
  #17  
Old 06-21-2007, 06:43 PM
slapshotw's Avatar
slapshotw slapshotw is offline
Veteran Croc
 
Join Date: Jun 2006
Posts: 5,164
Default Re: Help

Quote:
Originally Posted by php_dev View Post
Hi slapshotw,
i have already seen your example on another post about rsync but i don't know how to manage linux and so i don't know the differences for rsync and sync. But my db is really big and so if rsync can save resources can you explain me about it?
Rsync only sends over the changed parts of the database. Even with a 90db database, you have to assume that at least 50-70% of it isn't changing day after day. Rsync only sends the new and changed bits.
__________________
Follow me on Twitter! http://twitter.com/mrw
Reply With Quote
  #18  
Old 06-21-2007, 06:53 PM
php_dev php_dev is offline
Hatchling Croc
 
Join Date: May 2007
Posts: 19
Default Re: Help

Quote:
Originally Posted by slapshotw View Post
Rsync only sends over the changed parts of the database. Even with a 90db database, you have to assume that at least 50-70% of it isn't changing day after day. Rsync only sends the new and changed bits.
Thank you slapshotw.This is ok for me. Every day are inserted 1000 new rows and i want to backup only the new rows. In this way i can have updated backup without donload big files every time. What is the string for the rsync?
Reply With Quote
  #19  
Old 06-21-2007, 07:54 PM
Impavidus Impavidus is offline
Junior Croc
 
Join Date: Feb 2006
Posts: 155
Default Re: Help

PHP Code:
<?php 
if($_SERVER['REMOTE_ADDR']) { header("HTTP/1.1 404 Not Found"); exit; } // Allows only the Local Server

// DB Setting
$dbuser "";
$dbpass "";

// Settings
$time date("Y-m-d-H-i-s");
$filename "mysql_backup_" $time ".sql.gz";
$localpath "/home/username/mysqlbackups/";
$localfile $localpath $filename;
$nbackups 7// Number of days to keep backups

// Remote Setting
$mode 0// 0 = Remote Server Disabled; 1 = FTP;
$server "";
$remoteuser "";
$remotepass "";
$remotepath "path_on_remote/";
$remotefile $remotepath .  $filename;

exec('find ' $localpath ' -mtime +' .$nbackups ' -exec rm -f {}');
exec('mysqldump --user' $dbuser '  --password=' $dbpass ' --all-databases --single-transaction | gzip > ' $localpath $filename);

if(
$mode == 1) {
    
$ftp ftp_connect($server); 
    
$ftp_login ftp_login($ftp$remoteuser$remotepass); 
    
    if (!
$ftp || !$ftp_login) { 
        echo 
"FTP connection has failed!<br />";
        echo 
"Could not connect to $server<br />";
        if(
$ftp && !$ftp_login)
            echo 
"Incorrect username and/or password<br />"
    } else {
        echo 
"Connected to $server for user $remoteuser<br />";
        
$upload ftp_put($ftp$remotefile$localfileFTP_ASCII);
        if (!
$upload) {
            echo 
"FTP upload has failed!<br />";
        } else {
            echo 
"Uploaded $localfile to $server as $remotefile<br />";
        }
    }
    
ftp_close($ftp);
}
echo 
"Done $time";
?>
Reply With Quote
  #20  
Old 06-21-2007, 08:11 PM
Impavidus Impavidus is offline
Junior Croc
 
Join Date: Feb 2006
Posts: 155
Default Re: Help

Quote:
I want to backup only the new rows
I do not think that is possible. You would still need to do a mysql dump and use rsync to transer the change part of the file to a remote server. I not good at rsync yet!
Reply With Quote
  #21  
Old 06-21-2007, 08:13 PM
php_dev php_dev is offline
Hatchling Croc
 
Join Date: May 2007
Posts: 19
Default Re: Help

Thank Impavidus. Great script.
Reply With Quote
  #22  
Old 06-21-2007, 08:34 PM
php_dev php_dev is offline
Hatchling Croc
 
Join Date: May 2007
Posts: 19
Default Re: Help

Hi Impavidus,
If the script allow only local server how i do to start the file?
Reply With Quote
  #23  
Old 06-21-2007, 08:42 PM
Impavidus Impavidus is offline
Junior Croc
 
Join Date: Feb 2006
Posts: 155
Default Re: Help

cron job with the following command:
Code:
php /home/username/path_to_backup_script/backupmysql.php
You can comment out the first line to test it in a browser, but I would not recommend keeping it commented out.
Reply With Quote
  #24  
Old 06-21-2007, 08:46 PM
php_dev php_dev is offline
Hatchling Croc
 
Join Date: May 2007
Posts: 19
Default Re: Help

Quote:
Originally Posted by Impavidus View Post
cron job with the following command:
Code:
php /home/username/path_to_backup_script/backupmysql.php
You can comment out the first line to test it in a browser, but I would not recommend keeping it commented out.
Done! I have just uploaded the file and started the cronjob. It work fine! Thank you.I am sure your script will be useful for more others users too.
Reply With Quote
  #25  
Old 06-21-2007, 09:05 PM
Impavidus Impavidus is offline
Junior Croc
 
Join Date: Feb 2006
Posts: 155
Default Re: Help

I glad that the script works fine and everthing else works.

Reply With Quote
Reply

Bookmarks

Thread Tools

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

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

Forum Jump

All times are GMT -6. The time now is 03:33 PM.