FTP Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationFTP Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 22nd, 2003, 10:52 PM
Pusher Pusher is offline
Punk
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 29 Pusher User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Backing Up Table Structure/Data Via FTP?

Iwas wondering if anyone could lead me in the direction(If this is possible), to construct code that would do the following. Take a MySQL table, and backup the structure and data to a file(automatially). Then, take the file, and send a copy of it to another FTP.

Example:

Backup Code --> Creates File 1 with Structure and Data(located on www.mysite.com)

File 1(Backup data) ---> Stored Locally(www.mysite.com)

File 1 Copy and Send --> This file is sent to www.mybackupsite.com

I'm trying to make this all automated, so it would make the backup every 24 hours. I'm not looking for links to the manual please... Just working examples I can learn from and build off of. I doubt this is even possible... But if it is, all help is appreciated as always.

Regards,
Pusher

Reply With Quote
  #2  
Old March 23rd, 2003, 09:01 AM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,969 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 22 h 42 m 50 sec
Reputation Power: 184
Depends on your ISPīs restrictions on server-side programming.

One way (how my backups work):
I have a php script. It calls "mysqldump" (my ISP enabled it for me) and stores the database to a file. I also run it thru gzip for compression:
Code:
<?
  system("mysqldump -umyuser -pmypw mydb | gzip > backup.sql.gz");
?>

Then have another script on the backup server that does this:

- call the backup script via lynx:
lynx --dump http://mysite.com/make_db_backup.php
- download the backup file:
ftp -n < get_backup.ftp

where get_backup.ftp contains:
Code:
open www.mysite.com
user myname mypw
pasv (I need to use passive transfers)
get backup.sql.gz ./backup.sql.gz
bye

(be careful with the get_backup.ftp. In a shared hosting environemnt people could steal your password from it! And put it outside the DocumentRoot anyway!)

I canīt give you full code as first it is (C) by our company and I am not allowed to and second, the setup is very individual, so the scripts as such would probably not be of any use for you.

Did you get the idea from this?
__________________
--
Manuel Hirsch - Linux, FreeBSD, programming, administration articles, tutorials and more.

Reply With Quote
  #3  
Old March 23rd, 2003, 12:05 PM
Pusher Pusher is offline
Punk
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 29 Pusher User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Yes... Several. That's exactly the kind of input i'm looking for. I wasn't even sure if this idea could be done. It's worth a try. The server my client uses is his own private, so I'm not worried about the password security, but I do appreciate you saying that. I'll throw more questions as they come, but this is very helpful for a start.

Thank You,
Pusher

Reply With Quote
  #4  
Old March 23rd, 2003, 01:29 PM
Hero Zzyzzx's Avatar
Hero Zzyzzx Hero Zzyzzx is offline
11
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jul 2001
Location: Lynn, MA
Posts: 4,635 Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 23 h 44 m 19 sec
Reputation Power: 77
Send a message via AIM to Hero Zzyzzx
Assuming the machine you want to connect to allows remote connections, you don't even have to run a script on that end. . .Just run mysqldump remotely on the local machine, calling out to the database you want to backup

Something like this on the local machine:
Code:
mysqldump -C -u username -h www.remote.machine.com --add-drop-table --password=pass -al database_to_backup | gzip > /home/user/backup.gz


Put this in your crontab and you've got a gzipped backup at whatever interval you want. Be aware that this exposes the MySQL password on the remote machine in the local machine's crontab, but this may or may not be an issue.

The paranoid would set up a read-only account for backups on the remote machine, as a failsafe should someone attempt to mess around. On a well-configured host, users shouldn't be able to see each others crontabs.

Last edited by Hero Zzyzzx : March 23rd, 2003 at 01:33 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationFTP Help > Backing Up Table Structure/Data Via FTP?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT