Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
ncBash
/
mcBash
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 482560f6
authored
Dec 05, 2013
by
sn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
1 parent
045d2d4c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
33 deletions
bin/exportMysql.sh
bin/mcImportMysql.sh
bin/exportMysql.sh
View file @
482560f
#!/bin/bash
#
# @package freeSN
# @author dev@mensch.coop
# @package export_import
# @since 20131205 @author frederick@netz.coop
#
# exportiert eine Datenbank
#
. basepath.inc.sh
.
"
$__PATH_to_mcBash
/include.inc.sh"
execute
=
1
mc_h1
$0
$1
$2
mc_parameter
"1"
"1"
"
$1
"
"mysql Datenbank (muss vorhanden sein)"
mc_parameter
"2"
"0"
"
$2
"
"Datenbankbenutzer (optional default root)"
mc_parameter
"3"
"0"
"
$3
"
"Datenbankpasswort (optional)"
if
[
-z
$1
]
;
then
mc_h2
"Abruch bitte geben Sie als ersten Parameter eine Datenbank an"
mc_e
"1 Parameter: Datenbankname"
mc_e
"2 Parameter: Simulationsbit"
mc_e
"3 Parameter: Datenbankbenutzer (default root)"
mc_e
"4 Parameter: Datenbankpasswort"
exit
fi
if
[
-z
$2
]
;
then
mc_e
"Simulation (bitte geben Sie als zweiten Parameter 1 fuer Programm ausfuehren an)"
fi
if
[
-z
$3
]
;
then
user
=
'root'
else
user
=
$
3
user
=
$
2
fi
if
[
-z
$
4
]
;
then
if
[
-z
$
3
]
;
then
password
=
' -p '
else
password
=
" --password=
$
4
"
password
=
" --password=
$
3
"
fi
DATETIME
=
$(
date +
"%Y%m%d_%H%M%S"
)
BACKUPFILE
=
"mysql.
$1
.
$DATETIME
.sql"
mc_bashsu
"mysqldump --single-transaction --default-character-set=utf8 -u
$user
$password
$1
>
$BACKUPFILE
"
$
2
mc_bashsu
"tar -czf
$BACKUPFILE
.tar.gz
$BACKUPFILE
"
$
2
mc_bashsu
"rm
$BACKUPFILE
"
$
2
mc_bashsu
"mysqldump --single-transaction --default-character-set=utf8 -u
$user
$password
$1
>
$BACKUPFILE
"
$
execute
mc_bashsu
"tar -czf
$BACKUPFILE
.tar.gz
$BACKUPFILE
"
$
execute
mc_bashsu
"rm
$BACKUPFILE
"
$
execute
bin/mcImportMysql.sh
View file @
482560f
#!/bin/bash
#
# @package freeSN
# @author dev@mensch.coop
# @package export_import
# @since 20131205 @author frederick@netz.coop
#
# erstellt Datenbank, Benutzer und importiert SQL Datei
#
. basepath.inc.sh
.
"
$__PATH_to_mcBash
/include.inc.sh"
mc_h1
$0
$1
$2
$3
mc_parameter
"1"
"1"
"
$1
"
"mysql.sql.tar.gz import Datei"
mc_parameter
"2"
"1"
"
$2
"
"mysql Datenbank"
mc_parameter
"3"
"0"
"
$3
"
"mysql Benutzer"
mc_parameter
"4"
"0"
"
$4
"
"mysql Passwort"
execute
=
1
mc_h1
$0
$1
$2
$3
$4
mc_parameter
"1"
"1"
"
$1
"
"mysql.sql import Datei"
mc_parameter
"2"
"1"
"
$2
"
"mysql Datenbank (darf nicht vorhanden sein)"
mc_parameter
"3"
"0"
"
$3
"
"mysql Benutzer (default root)"
mc_parameter
"4"
"0"
"
$4
"
"mysql Passwort "
mc_parameter
"5"
"0"
"
$5
"
"Datenbank Benutzer "
mc_parameter
"6"
"0"
"
$6
"
"Datenbank Benutzer Passwort )"
if
[
-z
$3
]
;
then
...
...
@@ -25,6 +32,15 @@ if [ -z $4 ] ; then
password
=
" --password=
$4
"
fi
mc_bashsu
"mysql -u
$user
$password
-e
\"
create database
$2
\"
"
$execute
if
[
-z
$5
]
;
then
mc_e
"es wird kein Datenbankbenutzer für die Datenbank
$2
erstellt"
else
mc_parameter
"6"
"1"
"
$6
"
"Datenbank Benutzer Passwort"
'Passwort muss angegeben werden, wenn Benutzer erstellt werden soll!!'
mc_bashsu
"mysql -u
$user
$password
-e
\"
CREATE user '
$5
'@'localhost' IDENTIFIED BY '
$6
';
\"
"
$execute
mc_bashsu
"mysql -u
$user
$password
-e
\"
GRANT ALL ON
$2
.* TO '
$5
'@'localhost';
\"
"
$execute
fi
tar -xzf
$1
$__PATH_to_Temp
/
$1
.sql
mc_bashsu
"mysql -u
$user
$password
$2
<
$1
.sql"
\ No newline at end of file
mc_bashsu
"mysql -u
$user
$password
$2
<
$1
"
$execute
\ No newline at end of file
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment