|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
||||
|
||||
|
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. |
![]() |
| Viewing: Dev Shed Forums > System Administration > FTP Help > Backing Up Table Structure/Data Via FTP? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|