aunquarra Posted February 18, 2008 Share Posted February 18, 2008 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? Quote Link to comment Share on other sites More sharing options...
PHP Monkeh Posted February 18, 2008 Share Posted February 18, 2008 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. Quote Link to comment Share on other sites More sharing options...
aunquarra Posted February 18, 2008 Author Share Posted February 18, 2008 To clarify, the backup.sql file is on the DB server itself, in a 0777 directory. That said, I didn't call on it using the full path, since my shell was already in the same directory. Quote Link to comment Share on other sites More sharing options...
PHP Monkeh Posted February 18, 2008 Share Posted February 18, 2008 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? Quote Link to comment Share on other sites More sharing options...
aunquarra Posted February 18, 2008 Author Share Posted February 18, 2008 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. Quote Link to comment Share on other sites More sharing options...
aschk Posted February 19, 2008 Share Posted February 19, 2008 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.