[cPanel] Auto MySQL backup

Stanz

New Member
Messages
76
Reaction score
0
Points
0
Download the script, attached below.

Open the .php file in the attached .zip file & edit it.
Upload the script to your site (create a new directory) for example yoursite.com/sqlbackup.
CHMOD the new directory (folder) to 777.

Go to your CPanel and click on Cron Jobs. Then click on Standard.

Where it says "Command to run:" type
/home/username/public_html/sqlbackup/backupdb.php
Change the username to your username, and edit the path to where the script is located.

Set the time you want the Cron Job to run in the Minute(s) and Hour(s) boxes.

Warning: Do not do this in Hour(s) or Minute(s) or you account can be suspended for too much CPU usage. Here's the rest of the instructions:

Now it's time to say when it will backup the DBs. If you want to run it once a week, pick a day from the Weekday(s) box. If you want to run it once a month, select a date from the Day(s) box and leave the Month(s) box at Every Month.

Click Save Crontab and you're done.

Note: This only works for cPanel software.
You may use the script to backup if u dont have cPanel.
But you wont be able to use this tutorial without cPanel.

PS: You can make the script to email the backup,
or upload it to the directory you set in the script.. (requires setup)
This is only mySQL backup, not the whole site!!
and em.. its very usefull for forums..
 

Attachments

  • backupdb.zip
    3.1 KB · Views: 611

Corey

I Break Things
Staff member
Messages
34,553
Reaction score
203
Points
63
Nice post, thanks Stanz :)

-Corey
 

Stanz

New Member
Messages
76
Reaction score
0
Points
0
:biggrin: thanks
anyway, you can also just run the script.
if u want to backup manual...
that might save the server.. :smile:
 

brAddict

New Member
Messages
13
Reaction score
0
Points
0
Hi,

I've done everything requested but the cron still doesn't work.

Permissions are :

0777 for the folder where the file is.
0644 for the file itself (SQLBackup/backupdb.php)
User created for the database backup has those privileges :

select, insert, drop, create

This is what I receive by email :

/bin/sh: /home/braddict/public_html/SQLBackup/backupdb.php: Permission denied

When I try to execute the file from the site itself, this is what it shows :

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.


--

Any ideas ??
 

*Face

New Member
Messages
62
Reaction score
0
Points
0
The backupdb.php file needs execute permission, so it will probably need to be CHMOD to 755.
 

masshuu

Head of the Geese
Community Support
Enemy of the State
Messages
2,293
Reaction score
50
Points
48
hello, im getting the folowing email when its run with the cron, but it works fine when i run it via web browser.
ALERT - function within blacklist called: mail() (attacker 'REMOTE_ADDR not set', file '/home/masshuku/private_html/backupdb.php', line 125)
 

simon.evanz48

Member
Messages
32
Reaction score
0
Points
6
Thanks for your CRON example DB Backup script, I will give it a whirl to see what's what.
 
Top