| |||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| Soon to be RICHdoggie! | 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 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 |
| |
| | #2 (permalink) |
| Senior Member | 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. |
| |
| | #3 (permalink) | |||
| Soon to be RICHdoggie! | Quote:
That helps.Quote:
Quote:
When I know that everything works I am going to make it backup the db at midnight every second day. Thanks Tom | |||
| |
| | #4 (permalink) | |||
| Senior Member | Quote:
Quote:
| |||
| |
| | #6 (permalink) |
| Senior Member | 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 |
| |
| | #7 (permalink) |
| Soon to be RICHdoggie! | 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 |
| |
| | #8 (permalink) |
| Senior Member | erm i am not sure if the attachments are downloaded onto your computer.. =/ Joe
__________________ Fused Hosting Simplicity and Superiority. █████████████████████████████████████████████ Affordable web hosting solutions; shared, reseller, shoutcast, WHMSonic, proxy, dedicated and more! My computer is broken; new components have been ordered. ![]() |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |