|
27-08-2009, 01:00 | #1 |
Absinthe
Join Date: Jan 2007
Location: Chester
Posts: 2,345
|
SSH mysql backup
Evening, I'm trying to make a backup of a databse via SSH
so, i've connected to the database; Code:
mysql -h mysql14.streamline.net -u USERNAME -p Code:
mysqldump --opt -Q -shuwarrior1 -p shuwarrior1 > /backups/backup.sql |
27-08-2009, 02:21 | #2 |
Screaming Orgasm
Join Date: Jul 2006
Location: Newbury
Posts: 15,194
|
Code:
mysqldump --opt -Q -u username -p database | gzip -9 > backups/backup.sql.gz PS - I added on compression for you. May as well do it all in one go. If you don't want that, omit the gzip part. |
27-08-2009, 05:26 | #3 | ||
Preparing more tumbleweed
Join Date: Jun 2006
Location: Hawaii
Posts: 6,038
|
Quote:
SSH on to the server, you should have a command prompt that ends with the "#" symbol. From there run the mysqldump command like Mark suggested. I tend to do things slightly differently from Mark but it depends on what you're trying to do with the backup, more often than not I'm backing up databases in an environment where it's not too unusual for someone to have messed up a slave ('read only') server. To try to be a little nicer and make the backup run at a lower priority to standard tasks it's worth prefixing it with "nice", e.g. using Mark's command: Quote:
__________________
Mal: Define "interesting"? Wash: "Oh, God, oh, God, we're all gonna die"? |
||
27-08-2009, 10:35 | #4 |
Screaming Orgasm
Join Date: Jul 2006
Location: Newbury
Posts: 15,194
|
Good spot there, except it'll probably be shared hosting, so the prompt will be '$', not '#'.
PS - Will that 'nice' actually do anything? It won't be mysqldump taking the CPU resources. |
27-08-2009, 16:55 | #5 |
Preparing more tumbleweed
Join Date: Jun 2006
Location: Hawaii
Posts: 6,038
|
I think that's one that'll be debated back and forth. Depends on what the server is doing. mysqldump still does require a chunk of processing power whilst the server is working. Most often at the moment I'm dealing with all-in-one systems, full on LAMPs. Dropping the priority on mysqldump seems to help keep Apache far more responsive.
__________________
Mal: Define "interesting"? Wash: "Oh, God, oh, God, we're all gonna die"? |
27-08-2009, 18:56 | #6 |
Absinthe
Join Date: Jan 2007
Location: Chester
Posts: 2,345
|
yeah its a shared hosting package, so I've got the SSH access on my domains, and then the mysql is on a different server.
So I assumed that the mysqldump command wouldn't be able to backup the server if its being ran from my domain because it doesn't contain anything relating to the mysql server, just a username and database name which has nothing to do with my domain :/ Was a bit confusing using documentation from my host and also vB! |
Thread Tools | |
Display Modes | |
|
|