| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| Soon to be RICHdoggie! Join Date: Jan 2005 Location: UK
Posts: 2,408
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | 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?) ????: NamePros.com http://www.namepros.com/programming/252949-argh-help-me-lol-phpbb-backing.html Thanks a lot Tom |
| |
| | #2 (permalink) |
| NamePros Expert Join Date: Nov 2003 Location: Scotland
Posts: 5,069
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | 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. ????: NamePros.com http://www.namepros.com/showthread.php?t=252949 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. |
| |
| | THREAD STARTER #3 (permalink) | ||||||||||||
| Soon to be RICHdoggie! Join Date: Jan 2005 Location: UK
Posts: 2,408
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
That helps.
When I know that everything works I am going to make it backup the db at midnight every second day. Thanks Tom | ||||||||||||
| |
| | #4 (permalink) | ||||||||||||
| NamePros Expert Join Date: Nov 2003 Location: Scotland
Posts: 5,069
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
| ||||||||||||
| |
| | THREAD STARTER #5 (permalink) | ||||
| Soon to be RICHdoggie! Join Date: Jan 2005 Location: UK
Posts: 2,408
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() ????: NamePros.com http://www.namepros.com/showthread.php?t=252949 is there any way round it? like, putting it in a specific directory or something? Thanks Tom | ||||
| |
| | #6 (permalink) |
| NamePros Expert Join Date: Nov 2003 Location: Scotland
Posts: 5,069
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | 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 |
| |
| | THREAD STARTER #7 (permalink) |
| Soon to be RICHdoggie! Join Date: Jan 2005 Location: UK
Posts: 2,408
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | 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 Join Date: Oct 2005 Location: Kent ~ U.K.
Posts: 3,209
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | erm i am not sure if the attachments are downloaded onto your computer.. =/ Joe
__________________ Myself and "JackHeskett" are no longer associated with FusedHosting.net. Please pipe all PMs to admin [at] fusedhosting.net. |
| |