[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 10-31-2006, 01:46 PM   #1 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
 
Join Date: Jan 2005
Location: UK
Posts: 2,390
316.50 NP$ (Donate)

PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice


Argh help me! lol - phpbb backing up database via cron

I have this at the moment:

Code:
* * * * * mysqldump --add-drop-table -u ***** -p**** database_name > phpbb_backup-$(date +%m%d%Y).sql
which should do it every 1 minute right?

However, it dosen't seem to work. Where is the backup file, named phpbb_backup-*date*, going?

Also, is it possible to make another cron job to delete and phpbb_backup-*date*.sql files that are older than 2 weeks old?

Also, sorry, what does "--add-drop-table" mean? Will that copy EVERYTHING. So, if the whole db goes down, will the tables be copied (like "CREATE TABLE ** (blah...." and stuff? Also, will ALL the data be in there?)

Thanks a lot
Tom
PoorDoggie is offline  
Old 11-01-2006, 01:34 AM   #2 (permalink)
Senior Member
 
Peter's Avatar
 
Join Date: Nov 2003
Location: Scotland
Posts: 4,900
0.60 NP$ (Donate)

Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute

Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
if "--add-drop-table" is enabled it will add the drop table command into the database backup so if some of the tables exist when restoring it will delete the tables already there and upload the backed up tables. Usually if a table in the backup already exists and you try to do the backup without those commands the restoration will fail.

regarding where the file is have you tried doing a command like :-

locate phpbb_backup-

they are most likely in your root folder but not 100% sure.

also regarding how to delete the files after 2 weeks 1 thing you could do is put the files into a folder that php has complete access with (only have backups in it). Then iterate over the files with http://www.php.net/manual/ro/function.readdir.php ensuring that each entry is a proper file. Then with the file name strip out anything not to do with a date and then convert it to a unix timestamp. Then simply compare it to mktime()-1209600 which is the unix timestamp for 14 days ago from the current time.

To compare them simply have:-

if($file_time<$delete_timestamp)
{
unlink $filename
}

where $file_time is the timestamp from your file and $delete_timestamp is the timestamp for 14 days ago.
Peter is offline  
Old 11-01-2006, 01:10 PM   #3 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
 
Join Date: Jan 2005
Location: UK
Posts: 2,390
316.50 NP$ (Donate)

PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice


Quote:
Originally Posted by filth@flexiwebhost
if "--add-drop-table" is enabled it will add the drop table command into the database backup so if some of the tables exist when restoring it will delete the tables already there and upload the backed up tables. Usually if a table in the backup already exists and you try to do the backup without those commands the restoration will fail.
Aha... thanks a lot That helps.

Quote:
regarding where the file is have you tried doing a command like :-

locate phpbb_backup-

they are most likely in your root folder but not 100% sure.
err.... what? lol

Quote:
also regarding how to delete the files after 2 weeks 1 thing you could do is put the files into a folder that php has complete access with (only have backups in it). Then iterate over the files with http://www.php.net/manual/ro/function.readdir.php ensuring that each entry is a proper file. Then with the file name strip out anything not to do with a date and then convert it to a unix timestamp. Then simply compare it to mktime()-1209600 which is the unix timestamp for 14 days ago from the current time.

To compare them simply have:-

if($file_time<$delete_timestamp)
{
unlink $filename
}

where $file_time is the timestamp from your file and $delete_timestamp is the timestamp for 14 days ago.
Ok, so I make a php file that looks for files to delete, but how do I automate that to run at the same time as the database backup.

When I know that everything works I am going to make it backup the db at midnight every second day.

Thanks
Tom
PoorDoggie is offline  
Old 11-01-2006, 01:49 PM   #4 (permalink)
Senior Member
 
Peter's Avatar
 
Join Date: Nov 2003
Location: Scotland
Posts: 4,900
0.60 NP$ (Donate)

Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute

Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
Quote:
Originally Posted by PoorDoggie
Ok, so I make a php file that looks for files to delete, but how do I automate that to run at the same time as the database backup.

When I know that everything works I am going to make it backup the db at midnight every second day.

Thanks
Tom
Run the script through a cron as well immediately after the backup cron.

Quote:
Originally Posted by PoorDoggie
Quote:
regarding where the file is have you tried doing a command like :-

locate phpbb_backup-

they are most likely in your root folder but not 100% sure.
err.... what? lol
if you have ssh access to the server you can use that command to find where files are.
Peter is offline  
Old 11-01-2006, 01:54 PM   #5 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
 
Join Date: Jan 2005
Location: UK
Posts: 2,390
316.50 NP$ (Donate)

PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice


Quote:
Originally Posted by filth@flexiwebhost
if you have ssh access to the server you can use that command to find where files are.
err... no

is there any way round it? like, putting it in a specific directory or something?

Thanks
Tom
PoorDoggie is offline  
Old 11-01-2006, 03:28 PM   #6 (permalink)
Senior Member
 
Peter's Avatar
 
Join Date: Nov 2003
Location: Scotland
Posts: 4,900
0.60 NP$ (Donate)

Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute

Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
ok the best way to sort it to do what you want is to create a folder on your hosting package preferably not web accessible (if it is restrict access using htaccess)

now in the cron command instead of just having the filename make sure you specify the full server path to the newly created folder
Peter is offline  
Old 11-03-2006, 01:29 AM   #7 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
 
Join Date: Jan 2005
Location: UK
Posts: 2,390
316.50 NP$ (Donate)

PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice


no that didn't work either.

What I did do though, was create a php script that emailed me, and ran that every minute, and that worked, so all I did was to just take the query, put into php, make a file and then have it email it to me.

I think email is going to be better anyway... although I can't delete old copies as easilly. I use thunderbird, so aren't all attachments downloaded to my computer when I get the email anyway? If my server goes down then I will still have the backups here

Tom
PoorDoggie is offline  
Old 11-05-2006, 07:09 AM   #8 (permalink)
Joe
Senior Member
 
Join Date: Oct 2005
Location: Kent ~ U.K.
Posts: 3,246
88.85 NP$ (Donate)

Joe has much to be proud ofJoe has much to be proud ofJoe has much to be proud ofJoe has much to be proud ofJoe has much to be proud ofJoe has much to be proud ofJoe has much to be proud ofJoe has much to be proud ofJoe has much to be proud ofJoe has much to be proud of

Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
erm
i am not sure if the attachments are downloaded onto your computer.. =/

Joe
Joe is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

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


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85