Jump to content
TennShadow

DB Backup Script

Recommended Posts

Hey guy,

I'm looking for a backup script I can run as a cron job that will backup, compress, and the email me my databases nightly. I had a script several years ago that did just that but I don't have it anymore and my googling magic is not strong on this one. My host backups my site daily but I want the added protection of my databases being backed up off site from the host. Any help would be great.

Thanks!

Share this post


Link to post
Share on other sites

Ask and it will be given to you

Matthew 7:7

backup.php

Put the backup.php in your admin folder and you can call it in the crop by getting the address from here

ebe92f6fbd824f6b84e704dba22b87c1.png

by replacing maintenance.php with backup.php

Share this post


Link to post
Share on other sites

Awesome - thank you for this.

I got a couple errors with this. First, it didn't like my complex password until I put the password in quotes. Then that error went away but then got a different one. No backup file is created or emailed. I did get the email that the file was suppose to be attached to but there was nothing attached due to the below errors.

This was in the error logs.

[13-Dec-2016 00:25:01 UTC] PHP Warning: session_start(): Cannot send session cookie - headers already sent in /home/xxxxxx/public_html/core/codon.config.php on line 40
[13-Dec-2016 00:25:01 UTC] PHP Warning: session_start(): Cannot send session cache limiter - headers already sent in /home/xxxxxx/public_html/core/codon.config.php on line 40

This is from the email it sent me.

<br />
<b>Notice</b>: Undefined index: DOCUMENT_ROOT in <b>/home/xxxxxx/public_html/admin/backup.php</b> on line <b>35</b><br />
<br />
<b>Notice</b>: Use of undefined constant localhost - assumed 'localhost' in <b>/home/xxxxxx/public_html/admin/backup.php</b> on line <b>37</b><br />
<br />
<b>Notice</b>: Use of undefined constant MYDBNAME_REMOVED - assumed 'MYDBNAME_REMOVED' in <b>/home/xxxxxx/public_html/admin/backup.php</b> on line <b>38</b><br />
<br />
<b>Notice</b>: Use of undefined constant MYDBNAME_REMOVED - assumed 'MYDBNAME_REMOVED' in <b>/home/xxxxxx/public_html/admin/backup.php</b> on line <b>40</b><br />
sh: -c: line 0: syntax error near unexpected token `)'
sh: -c: line 0: `mysqldump --hex-blob --routines --skip-lock-tables --log-error=mysqldump_error.log -h localhost -u MYDBNAME_REMOVED -pPASSWORD MYDBNAME_REMOVED > 20161213_MYDBNAME.sql'
mysqldump for localhost : MYDBNAME_REMOVED failed with a return code of 1
Error message was:
tail: cannot open `mysqldump_error.log' for reading: No such file or directory
-
Backup Completed

Share this post


Link to post
Share on other sites

[13-Dec-2016 04:24:01 Etc/GMT] PHP Warning: session_start(): Cannot send session cookie - headers already sent in /home/litejoro/public_html/crew/core/codon.config.php on line 40
[13-Dec-2016 04:24:01 Etc/GMT] PHP Warning: session_start(): Cannot send session cache limiter - headers already sent in /home/litejoro/public_html/crew/core/codon.config.php on line 40
[13-Dec-2016 04:24:01 Etc/GMT] PHP Warning: Creating default object from empty value in /home/litejoro/public_html/crew/admin/backup.php on line 26
[13-Dec-2016 04:24:01 Etc/GMT] PHP Notice: Undefined index: DOCUMENT_ROOT in /home/litejoro/public_html/crew/admin/backup.php on line 35

I have these errors too but a backup File is getting created. Is the script supposed to email you with the SQL database attached to the email?

This is what I get in email :

<br />
<b>Warning</b>:  Creating default object from empty value in <b>/home/litejoro/public_html/crew/admin/backup.php</b> on line <b>26</b><br />
<br />
<b>Notice</b>:  Undefined index: DOCUMENT_ROOT in <b>/home/litejoro/public_html/crew/admin/backup.php</b> on line <b>35</b><br />
Warning: Using a password on the command line interface can be insecure.
Backup Completed

Edited by ShrikarG

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×