Thread: [SOLVED] Cron Based Database Backup
View Single Post
  #2 (permalink)  
Old 10-16-09, 10: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]
The Following User Says Thank You to End User For This Useful Post:
smithygotlost (10-18-09)