Current location: Hot Scripts Forums » Programming Languages » PHP » [SOLVED] Cron Based Database Backup


Cron Based Database Backup

Closed Thread
  #1 (permalink)  
Old 10-16-09, 10:20 AM
smithygotlost smithygotlost is offline
Aspiring Coder
 
Join Date: Jul 2006
Location: United Kingdom
Posts: 412
Thanks: 12
Thanked 3 Times in 3 Posts
Cron Based Database Backup

Now ive had a google and this seems to be a very complex area. but i wanna try and make a cron that runs every day at midnight back our database up to a file or email it to us. just not idea how to start.

How do i go about making php back the database up ?

Thanks for your help in advanced
Mike
__________________
Make People Friendly Say " Thanks "
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
  #2 (permalink)  
Old 10-16-09, 11:04 AM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
Quote:
Originally Posted by smithygotlost View Post
How do i go about making php back the database up ?
You don't need PHP. RUn this every night and it'll do a full backup and zip it up. Change the parts in BOLD and also the parts that say "/path/to/..."

#!/bin/bash

# generate the filename for the main DB
BACKUPFILE=$(date +%m-%d-%Y)-main.sql
echo -n "Main database backup file name is: $BACKUPFILE
"
# dump the database to a file
/path/to/mysqldump DBNAME -uDBUSER -pDBPASSWORD --quick -n> /path/to/backup/file/$BACKUPFILE

# zip the file up
/bin/gzip --best /path/to/backup/file/$BACKUPFILE
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
The Following User Says Thank You to End User For This Useful Post:
smithygotlost (10-18-09)
  #3 (permalink)  
Old 10-18-09, 01:16 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
The Following User Says Thank You to wirehopper For This Useful Post:
smithygotlost (10-18-09)
  #4 (permalink)  
Old 10-18-09, 03:06 PM
smithygotlost smithygotlost is offline
Aspiring Coder
 
Join Date: Jul 2006
Location: United Kingdom
Posts: 412
Thanks: 12
Thanked 3 Times in 3 Posts
O very nice

thank you, never thought of doing like that. cant wait to get this running
__________________
Make People Friendly Say " Thanks "
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Closed Thread

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
auto mysql database backup in windows xp triplebig Database 2 09-11-09 02:03 AM
Create Multiple Varibles Based On Database cebuy PHP 2 11-26-04 12:15 AM
database backup scorpioy PHP 1 09-27-04 10:59 AM
Declared Functions skipper23 PHP 4 12-17-03 11:06 AM
index page not showing up skipper23 PHP 3 12-15-03 02:10 PM


All times are GMT -5. The time now is 07:47 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.