Jump to content

quick question


aunquarra

Recommended Posts

I feel dumb for having to ask this, and I think I know the answer, but I want a second opinion.

 

I have SSHed into a DB server, and performed a "mysql -u [user] -p [dbname] < backup.sql" type command. The problem is, it's a big backup, and it's going to take a good while. I didn't think to do it from the local machine rather than SSH... And I'm probably going to need to pack up my laptop and leave before it's done.

 

Having seen how mySQL responds to having apache/php go away (it keeps on trucking on whatever PHP told it to do until it's done, even if PHP isn't listening anymore), I don't think I've ever just shut down an SSH session with such a large upload (usually I have the forethought to _not_ do it over SSH).

 

So what happens when I close my SSH client?

Link to comment
https://forums.phpfreaks.com/topic/91754-quick-question/
Share on other sites

Well I'm assuming the file's stored locally.  If you shut your SSH client that'll mean that MySQL won't have access to the file anymore... therefore shutting off completely (and I'm not sure what damage would be done).  Unless MySQL loads the entire file in to memory before performing the back-up, although I'm not sure about that.

 

Although a very simple question, I have a feeling it could get very complicated in here soon.

Link to comment
https://forums.phpfreaks.com/topic/91754-quick-question/#findComment-469950
Share on other sites

Well in that case I'd assume it's safe to go ahead and close your client.  MySQL will continue to import the file surely once the process has started, regardless of where the command came from, unless when you close your SSH client it issues a kill command to MySQL - which will stop the restore.

 

Are you brave enough to cancel it?  And is it vital that the restore is done tonight and can't wait till tomorrow?

Link to comment
https://forums.phpfreaks.com/topic/91754-quick-question/#findComment-469963
Share on other sites

Well, I dont think my SSH client would send a kill, but I would think that one sure way to prevent it would be to unplug the ethernet first, then close the client.

 

And, unfortunately, hourly crons are waiting on this restoral, and the workload is backing up. This is one of those "it needs to be done yesterday" things. And it might be running through the night anyway-- the backup.sql file is 4.5G.

Link to comment
https://forums.phpfreaks.com/topic/91754-quick-question/#findComment-469973
Share on other sites

No answer your question, the MySQL process will stop because it's tied to your SSH client process, and executed under that user. Thus once the user logs all the processes are terminated. If you want to run it in the background (and logout of SSH) then put "& > /dev/null" at the end and this should run it in the background and send the output to /dev/null (i think).

 

note: that linux command might not be quite right.

Link to comment
https://forums.phpfreaks.com/topic/91754-quick-question/#findComment-470392
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.