LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-10-2011, 09:30 AM   #1
SeSoX
LQ Newbie
 
Registered: Aug 2009
Posts: 18

Rep: Reputation: 0
Question MySQL backups cpanel style


Hi there,

I've got a server online and I'd like to get daily mysql backups. I think that the way cpanel does those backups is great so I'll like to implement something like that, I've got full access to the server.

So the way I use to do it with cpanel is just an wget of a web page like this and the sql file was created somehow in the background:

http://www.server.com/getsqlbackup/database_name.sql.gz

Should I do this with php ?
 
Old 01-11-2011, 02:45 AM   #2
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
The file .sql.gz suggests that a mysqldump was used to dump the full database contents in a .sql file, which was
subsequently compressed with gzip. Try looking up "mysqldump" to get started.
A strategy could be to
1) run a cron job on the machine running mysql to dump the database to a file & compress it (as a "backup" of the database)
2) run a cron job on a second machine to copy the backup file to another machine for safe(r) keeping
Step 2 can, but does not have to be, done by wget - which is used typically for web (HTTP) or FTP downloads.
It depends on how your mysql machine is set up for remote access by the second machine - ie if it is
configured for web access (apache), ftp access (vsftp), scp/sftp access (ssh), file sharing (nfs, samba)...
 
Old 01-11-2011, 03:16 AM   #3
SeSoX
LQ Newbie
 
Registered: Aug 2009
Posts: 18

Original Poster
Rep: Reputation: 0
Thanks for the reply timmeke

I know the basic use of mysqldump already

The thing about the step 1 is that the file will be created and left somewhere. I want the backup to be created when I access the link, which I will download at the same time and will be deleted once the download finishes. I was thinking that it could even be some kind of pipe so the file would never end up being on the disk. Not sure if that's possible.

I hope I explained myself but if not let me know and I'll do it with an example.
 
Old 01-11-2011, 04:57 AM   #4
SeSoX
LQ Newbie
 
Registered: Aug 2009
Posts: 18

Original Poster
Rep: Reputation: 0
Hey, I think I found a solution, still will have to make a few changes but I think this will work

http://stackoverflow.com/questions/4...p-or-otherwise
 
Old 01-11-2011, 06:19 AM   #5
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Streaming it to the client browser. Could work out.
Mysql dump files are plain text, so an appropriate content-type (or -disposition) is in order.

The only problem I may see is the size of the dump file.
A -disposition ("save to disk") might be a good idea, to avoid the browser from
trying to display the entire file (could be slow when you have several megabytes in size).
 
Old 01-11-2011, 06:31 AM   #6
SeSoX
LQ Newbie
 
Registered: Aug 2009
Posts: 18

Original Poster
Rep: Reputation: 0
Right now I'm using this two headers:

header('Content-Type: application/octet-stream');
header('Content-disposition: attachment; filename="file.qz"');


I did couple of tests and it works great
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cpanel/WHM Died at /usr/local/cpanel/Cpanel/Hulk.pm line 92. liang3391 Linux - Software 1 06-22-2009 02:02 PM
MySql + FC4 + cpanel - very strange behaviour ddaas Linux - Networking 4 11-01-2006 03:02 PM
LXer: Create Incremental Snapshot-style Backups With rSync And SSH LXer Syndicated Linux News 0 08-13-2006 08:21 PM
Restoring MySQL backups with mysql-administrator pnellesen Programming 0 04-25-2005 09:53 AM
cPanel & mySQL directories Alan Powell Linux - Newbie 1 04-26-2004 06:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration