Libro infantiles - MPAA - 0 Credit Cards - Credit Cards - Cheap Flights

PDA

View Full Version : Database backup?


trinh
Aug 2nd 2005, 8:00 am
Hey, I have a couple of databases under my "management" but I do not have phpMyAdmin or any other similar tool.

All I want to know is what code would I use (preferably PHP) to download a backup of these two databases.

What I want is for when this page is opened it to start a download of a database copy, ideally in .sql or .txt format.

Any ideas?

Or if this is not possible would it be possible to make the following script copy the backup to a directory?

Many thanks for any replies

mopacfan
Aug 2nd 2005, 8:55 am
What kind of databases are they? mysql? mssql????

trinh
Aug 3rd 2005, 6:20 am
Sorry, forgot :P

It is a MySQL database. I believe the MySQL version is somewhere in the 4's as is PHP.

stickman373
Aug 3rd 2005, 6:50 am
Why not just put a copy of phpMyAdmin on the server, it's free and easy to backup and restore then

forkqueue
Aug 3rd 2005, 7:34 am
If you've got shell access you can use the mysqldump tool.
With SSH keys you can write a script which will log in and backup up automatically.
phpMyAdmin is a better choice if you're not down with the command line.

plmerlin
Aug 3rd 2005, 9:19 am
Here are some PHP easy to install MySQL backup solution:

http://sourceforge.net/projects/pmbackup/ don't forget to put in a protected directory. Easy to install and use

One of my favorite is PHPmyBackup
http://sourceforge.net/projects/phpmybackup/ from which you can backup different servers and support scheduled backups :p

Let me know if it helps

my3cents
Aug 3rd 2005, 10:08 am
I use the mysqldump tool (comes with mysql) and the ftp the file(s) to another server. Two simple commands in a script will do it. The use cron to schedule it nightly or weekly, whatever suits you.

Don't have the commands with me, I will post them later if I get a chance.

my3cents
Aug 3rd 2005, 6:00 pm
Here is the script to backup your db in mysql into a gzip file:

mysqldump -h www.yourserver.com -p dbname | gzip >/home/db_bk/mysql-db.gz

frankm
Aug 3rd 2005, 6:14 pm
and check the mysqldump documentation, there are a lot of flags you can use to make it easier to restore a backup, or to make it dump faster, or to sort data etc.

what I do is running a cronjob at low-load hours (4:30AM) that dumps all databases and all tables to seperate zip files. the name of these files are
[database]/[table]/[day-of-the-week].dump.gz , where day-of-the-week is (Mon,Tue etc).
that gives me a backup of all data on the server the mysqld is running on. Make sure you save the backups on another disk (hardware! not partition) as the real mysql data is on. that will help you when a drive crashes (And trust me, they do)

then I got another server, that uses rsync to mirror the dump directory from the initial server. That is also a cronjob, ran every 4 hours (just to be sure I get the data as soon as possible)

to give you a detailed picture: I've got 4 servers, on 3 differenet networks that are all creating dumps locally, and all 4 are rsyncing the others.

--
when do you need to re-install a backup? when you just figured out there ARE no backups

trinh
Aug 4th 2005, 8:11 am
Thanks for the help.

I will try installing phpMyAdmin again.

Incase that don't work. Will this be the correct script to save the backup in the directory "games":

<?php


mysqldump -h w.myserver.com -p dbname | gzip >/home/public_html/games/mysql-db.gz;

?>

Or will that not work. Sorry to keep asking, I really am new to all this :(

EDIT: Had to remove the www from my domain as I need more posts to post links :confused:

RectangleMan
Aug 5th 2005, 11:38 pm
http://www.phpdump.com/

trinh
Aug 7th 2005, 3:17 am
Many, many thanks for that link. Does just what I want :D

RectangleMan
Aug 10th 2005, 11:58 am
That's my site btw.

Shoemoney
Aug 15th 2005, 8:01 am
That's my site btw.

double word score ;)