Jump to content

Recommended Posts

Hi,

 

I want to know is it possible to copy the file from 1 server to another server by using php scripts?

In my case:

I  plan to use mysqldump to backup my database inside a sql file,

so the generated backup file should be in the server.

 

Next I plan to use cron to run the backup daily and transfer the sql file(backup) to another server.

If It is not a server,but local pc, will it be done?

 

because I plan to use script download to a local pc folder and sharing the folder so that user can copy the file into their thumbdrive and can bring it home.

 

Is there any way to let me do that?

 

A few ways you could do this.

 

  • If your server has an ftp server setup you could use the ftp extension.
  • If you have shell access you could use scp via exec
  • If you have shell access you could simply map a remote drive using sshfs or nfs.

 

I don't see why you need to use php for this.

Thanks.. why shell script is better?

Any advantage over php?

Because most of the commands required in this operation such as mysqldump, sftp, ftp, scp, etc are all command line programs, so why use php?

Thanks.. why shell script is better?

Any advantage over php?

 

You just don't need php is all. Its just as easy to write your shell commands directly into your crontab. eg;

 

stamp=date +"%m-%d-%Y-%H:%M:%S"
0 5 * * * /usr/bin/mysqldump --opt databasename > /tmp/$stamp-dump.sql && scp /tmp/$stamp-dump.sql remotemachine:/path/to/backups/ && rm /tmp/$stamp-dump.sql

 

Done

What if I want to transfer the file to one of the window pc on my LAN?

Could I do that?

 

Example.

 

After the cron run every midnight to backup the database,

It will generate a sql file inside the server.

I want to transfer the sql file to a LAN (window) pc's sharing folder.

 

example the pc name was pc01,

its IPv4 in LAN was 192.168.1.3

the server used to generate sql file on LAN was 192.168.2.6

 

So I used

sftp pc01@192.168.1.3 ?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.