LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Transferring Files From A Remote Computer (https://www.linuxquestions.org/questions/linux-general-1/transferring-files-from-a-remote-computer-577799/)

TheBaker 08-17-2007 09:44 AM

Transferring Files From A Remote Computer
 
I have rather an interesting problem (or at least, I have a problem). I've been asked to make a backup of a MySQL database on a remote computer. I've been given an account on the computer which I can log into via SSH.

Unfortunately though, there's a problem with MySQL on the computer and they can't get it to start. So what I've resolved to do is take a copy of the MySQL data files which will serve as a backup until such time that MySQL is up and running and I can take a mysqldump.

To access the MySQL data files, I had to sudo su to the mysql user, and then I copied the files across to my users home directory on the remote machine (I created a folder with 0777 permissions so the mysql user could write to it).

So now I have a load of files owned by mysql in a remote directory owned by me, and I need to get them onto my local computer. But I'm not sure how to do this!

If the files were owned by me, I could just download them - but as they're not I keep getting Permission Denied errors. I've tried changing the owner, group and permissions but keep getting errors.

Any ideas? I'd be very grateful for any help.

N.B. My local computer is a Mac, but the remote computer is Linux.

trickykid 08-17-2007 09:45 AM

rsync or scp can copy files over ssh to and from remote servers to local machines.

TheBaker 08-17-2007 10:18 AM

And how would I use those? Would they work as my user, or would I have to be the mysql user to transfer them?

lakris 08-17-2007 10:50 AM

Quote:

Originally Posted by TheBaker (Post 2862073)
And how would I use those? Would they work as my user, or would I have to be the mysql user to transfer them?

If it is possible to login remotely with the mysql user, use from your own machine

scp -r mysql@remotemachine:/var/lib/mysql .
or
rsync -az mysql@remotemachine:/var/lib/mysql .
(check location of the mysql database dir)

The mysql user can change permissions on the files in the "0777" folder. One could zip them for easy handling. Only root can change owner.

And in case You can't login as mysql user, go to the other machine, sudo su to mysql user, cd to your normal users dir, and
scp -r 0777dir you@yourmachine:
or
rsync -az 0777dir you@yourmachine:
they will be owned by you on your machine.

trickykid 08-17-2007 11:41 AM

I wouldn't login as the mysql user and in some cases mysql doesn't have a valid shell or actual password (since it's used to run as a service).

Depending on the permissions, it should allow you to copy the files remotely to locally, if not, change the permissions or ownership temporarily, not like you can't change it back.. ;)

TheBaker 08-17-2007 02:22 PM

Thanks guys, that worked great.


All times are GMT -5. The time now is 11:56 AM.