cancel
Showing results for 
Search instead for 
Did you mean: 

Backing up your database

SoulBriski
Grafter
Posts: 179
Registered: ‎15-06-2007

Backing up your database

Has anybody written any php code yet to backup the MySQL database?
My plan is to login a secure part of my website and run a bit of script to back up all my data but i wondered if anybody else has already done this. It will be a lot quicker than using the PHP MyAdmin area etc
No point in re-inventing the wheel eh?
5 REPLIES 5
jelv
Community Veteran
Posts: 26,786
Thanks: 990
Fixes: 10
Registered: ‎10-04-2007

Re: Backing up your database

Have you tried http://mysql.com/products/tools/administrator/ ?
Run that on your PC specifying the server name as rumpus.plus.net or humbug.plus.net and backup direct to your PC. It's a lot faster than phpmyAdmin.
jelv (a.k.a Spoon Whittler)
   Why I have left Plusnet (warning: long post!)   
Broadband: Andrews & Arnold Home::1 (FTTC 80/20)
Line rental: Pulse 8 Home Line Rental (£14.40/month)
Mobile: iD mobile (£4/month)
SoulBriski
Grafter
Posts: 179
Registered: ‎15-06-2007

Re: Backing up your database

Thanks for your help. Looks like this could be the answer
Prod_Man
Grafter
Posts: 286
Registered: ‎04-08-2007

Re: Backing up your database

Could do it yourself in a number of ways,
and make it create an enitre snapshot of entire directory trees of your Webspace,
all in a Tar GZip..
backup.sh

#!/bin/sh
set $BACKUPDIR="~/path/to/backups"
echo Backing up Databse 'database_pn'... to filename 'database.sql'
mysqldump -h HOST -u USER -pPASSWORD database > "$BACKUPDIR/database.sql"
echo Backing Up Dev-Center Website & Database SQL... to filename site-`date '+%m/%d/%y'`-backup.tar.gz
tar cfz $BACKUPDIR/site-`date '+%m-%d-%y'`-backup.tar.gz *
echo Removing Temporary SQL File Backup
rm $BACKUPDIR/database.sql

You should replace "*" with direcotries needed followed by the asterisk,
else you'll fill up your webspace in the process of backing up.
Examples:
admin/*
logs/*
scripts/*...
Then you have two options of running it...
Directly via SSH or by utilising the PHP system()" command (or similar) and creating it around your own Adminstration system.
Hope this throws up some options.
Jim,
SoulBriski
Grafter
Posts: 179
Registered: ‎15-06-2007

Re: Backing up your database

Thanks for your help Jim.
In the meantime i had followed the suggestion from jelv and it gives me exactly what i need. However, because i administer my site from different places, creating my own administration script gives me more flexibilty instead of installing a stand-alone package on each pc that i work from. (Home, work, laptop etc) so in the long term, i will probably go down the scripting method.
As it happens, i've got the best of both worlds for now, thanks
Prod_Man
Grafter
Posts: 286
Registered: ‎04-08-2007

Re: Backing up your database

Ahh,
good at least you have a solution which works for you.
That's all that matters Smiley
And no problem, I'm glad you saw some kind of use in it Cheesy
Jim,