LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-15-2015, 01:44 AM   #16
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553

Quote:
Originally Posted by mike2010 View Post
I was checking out the script TenTenths recommended just now. It seems decent, but there's a much shorter one here that was also recommended to me -
That's pretty much the same script, with no remarks, no progress indication, no stopping of slave replication, etc.
Also, it does the gzip of the database "on the fly", so if you have a huge database then your backup could spend quite a while dumping that one database.
My script does the database dumping part and then does the compression.

If having the script "shorter" is THAT important to you, here's mine with the remarks, progress, and slave stuff taken out.

Code:
#!/bin/bash

BACKUPDIR=/backup
DBLIST="your list of databases here"
USEROPTIONS="-ubackup -pQwErTy123"
DUMPOPTIONS="--lock-all-tables"
BINDIR=/usr/bin
BACKUPDATE=$(/bin/date +a)

for DATABASE in ${DBLIST} ; do
  ${BINDIR}/mysqldump ${USEROPTIONS} ${DUMPOPTIONS} ${DATABASE} > ${BACKUPDIR}/${DATABASE}_${BACKUPDATE}.sql
done

${BINDIR}/gzip -f ${BACKUPDIR}/*_${BACKUPDATE}.sql
Oh look, it's actually 2 lines shorter.

Quote:
Originally Posted by mike2010 View Post
looks like nobody cares..
Yup, bored now.
 
Old 04-15-2015, 09:59 AM   #17
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Quote:
Originally Posted by mike2010 View Post
looks like nobody cares..
So what was the question then?
I don't assume you were sitting there leaning back waiting for us to improve the script to a level that it is satisfactory for you.
Since you had the various scripts showing clearly how to solve your problems, I don't understand what else you were waiting for. There is not much more you can do to backup a database.

@TenTenths: My preference would be to store the password in a my.cnf, owned by the user who's credentials are used for accessing the database.

jlinkels
 
Old 04-15-2015, 10:03 AM   #18
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Quote:
Originally Posted by jlinkels View Post
@TenTenths: My preference would be to store the password in a my.cnf, owned by the user who's credentials are used for accessing the database.
Yup, would make sense for a multi-user environment.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Gimp 2.8: So Close, Yet So Far, Yet So Close LXer Syndicated Linux News 0 03-29-2012 11:42 PM
close terminal mean close background process? Niceman2005 Linux - General 7 05-27-2010 02:58 PM
how to close port 1050 please help how to close it. mr norm Linux - General 1 09-12-2008 07:57 AM
mplayer 'close all' doesn't close anything allelopath Linux - Software 2 12-08-2005 09:40 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration