Register Members List Search Today's Posts Mark Forums Read

Reply
 
Article Options
Site and mySQL backups via cron
Jase2
Join Date: Dec 2007
Posts: 1,575

USA
by Jase2 Jase2 is offline 03 Feb 2008

Site Backup via Cron:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


----------------------------------------
MySQL backup via cron - Emailed to You:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

----------------------------------------

MySQL backup via cron - FTPed to You
:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


All these scripts should have the .php extension, and the file should have 755 permissions.

Don't forget to change the first few variables to the beginning of the scripts to match your site details. Also note, that you will need to set-up a cron job via your cPanel, with a path to the script such as "php /home/username/path-to-the-php-script" (without the "" and replacing path-to-the-php-script with your actual path to it).

That's it, enjoy!

Regards Jason

Last edited by Jase2; 03 Feb 2008 at 20:02..
Views: 8098
Reply With Quote
Comments
  #2  
Old 04 Jul 2008, 16:17
tazzarkin tazzarkin is offline
 
Join Date: Nov 2007
Thank you for this. I don't understand why no one ever posted a thank you. Well, anyways, this will help a lot.
Reply With Quote
  #3  
Old 15 Jul 2008, 20:15
kp^ kp^ is offline
 
Join Date: Apr 2008
Yes, thank you!
Reply With Quote
  #4  
Old 30 Jul 2008, 17:20
Markowitch Markowitch is offline
 
Join Date: Nov 2005
How do you close your board during the backup?
Reply With Quote
  #5  
Old 14 Jan 2009, 05:02
jkcerda jkcerda is offline
 
Join Date: Mar 2008
coooooool
Reply With Quote
  #6  
Old 08 Mar 2009, 15:13
Jasem's Avatar
Jasem Jasem is offline
 
Join Date: Feb 2006
Location: www.menokia.com
Excellent, thank you!
__________________
games
Forum Nokia
Reply With Quote
  #7  
Old 16 May 2009, 22:28
sheppardzwc sheppardzwc is offline
 
Join Date: Dec 2008
Location: South Carolina
Real name: Zach
Just to bump, THANKS! This is exactly what I was looking for.

Just a question -- how can I fix this?:

will@rodan:/tth/cron$ php backup.php

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 474195519 bytes) in /tth/cron/backup.php on line 20
Reply With Quote
  #8  
Old 18 May 2009, 08:10
dbembibre's Avatar
dbembibre dbembibre is offline
 
Join Date: Oct 2004
Real name: Daniel
Originally Posted by sheppardzwc View Post
Just to bump, THANKS! This is exactly what I was looking for.

Just a question -- how can I fix this?:

will@rodan:/tth/cron$ php backup.php

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 474195519 bytes) in /tth/cron/backup.php on line 20
Increase memory_limit in php.ini
Reply With Quote
  #9  
Old 21 May 2009, 03:29
ubcforums's Avatar
ubcforums ubcforums is offline
 
Join Date: Apr 2009
thanks..this saves lot of time
Reply With Quote
  #10  
Old 22 May 2009, 14:07
squishi squishi is offline
 
Join Date: May 2006
Thanks for the code.
Though, a mysql backup by email? I rather not receive 1GB of email attachments. :-)
Reply With Quote
  #11  
Old 01 Jun 2009, 15:55
geckoz's Avatar
geckoz geckoz is offline
 
Join Date: Aug 2007
Doesn't work for me ... I think you must have SAFE MODE ON but I don't want to turn it off.
__________________
My Favourite Sites: 5000+ Free Avatars
Reply With Quote
  #12  
Old 09 Mar 2011, 22:48
Old-Git Old-Git is offline
 
Join Date: Dec 2009
The tech support guy at my hosting gave me the following info to use Cron, via Cpanel, to do a backup of my database every Sunday night at midnight.

In order to do a backup of your database through a cron job, you can set this up in cpanel. Click on Cron Job, then select Standard or Advanced. You can select the backup frequency that you need then enter the command to backup. Here is a sample cron job:

0 0 * * 0

date=`date -I`; /usr/bin/mysqldump -uDBUSERNAME -pPASSWORD dbname > /home/CPANELUSERNAME/FILE_NAME_HOME_DIRECTORY$date.sql

This cron job will do a backup of the database every Sunday at midnight. Then it will save the backup with the current date appended to the file name.

A few notes:

-uDBUSERNAME – there should be no space between -u and DBUSERNAME, DBUSERNAME is the username of the database you are trying to backup.

-pPASSWORD – there should be no space between -p and PASSWORD, PASSWORD is the password of the database user.

dbname – this is the name of your database.

/home/CPANEL_USERNAME/BACKUP_NAME$date.sql – cpanelusername is your username to log into cpanel, and this will save the backup in your home directory (you can change it to whatever directory you want). You can call the backup whatever you wish but adding $date at the end will append the date to that backup.
I haven't tried this yet (just received it) but thought I'd offer it here for comment!

Rgds
__________________
My Wife married Mr Right, she simply failed to appreciate that my first name is always!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Article Options

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


New To Site? Need Help?

All times are GMT. The time now is 11:20.

Layout Options | Width: Wide Color: