1
1
<?xml version =" 1.0" encoding =" UTF-8" ?>
2
2
<project name =" DataBase project builder" basedir =" ." default =" help" >
3
- <!-- Load environment specific configuration default is build.properties -->
4
- <target name =" db:check-configuration" >
5
- <if >
6
- <available file =" config/db.${build.env}.properties" property =" " />
7
- <then >
8
- <property file =" config/db.${build.env}.properties" override =" false" />
9
- </then >
10
- <else >
11
- <if >
12
- <available file =" config/db.properties" property =" " />
13
- <then >
14
- <property file =" config/db.properties" override =" false" />
15
- </then >
16
- <else >
17
- <fail message =" Property file does not defined! Please create db.properties!" />
18
- </else >
19
- </if >
20
- </else >
21
- </if >
22
- </target >
3
+ <!-- Load environment specific configuration default is build.properties -->
4
+ <target name =" db:check-configuration" >
5
+ <if >
6
+ <available file =" config/db.${build.env}.properties" property =" " />
7
+ <then >
8
+ <property file =" config/db.${build.env}.properties" override =" false" />
9
+ </then >
10
+ <else >
11
+ <if >
12
+ <available file =" config/db.properties" property =" " />
13
+ <then >
14
+ <property file =" config/db.properties" override =" false" />
15
+ </then >
16
+ <else >
17
+ <fail message =" Property file does not defined! Please create db.properties!" />
18
+ </else >
19
+ </if >
20
+ </else >
21
+ </if >
22
+ </target >
23
23
24
- <if >
25
- <os family =" unix" />
26
- <then >
27
- <php expression =" str_replace(array('(', ')'), array('\(', '\)'), '${db.pass}');" returnProperty =" db.pass.cmd" />
28
- </then >
29
- <else >
30
- <property name =" db.pass.cmd" value =" ${db.pass}" />
31
- </else >
32
- </if >
24
+ <if >
25
+ <os family =" unix" />
26
+ <then >
27
+ <php expression =" str_replace(array('(', ')'), array('\(', '\)'), '${db.pass}');" returnProperty =" db.pass.cmd" />
28
+ </then >
29
+ <else >
30
+ <property name =" db.pass.cmd" value =" ${db.pass}" />
31
+ </else >
32
+ </if >
33
33
34
34
<!-- ################################################################################-->
35
- <target name =" db:help" depends =" db:check-configuration" description =" Print help for current phing command" >
36
- <echo msg =" Specific database commands:" />
37
- <echo msg =' - db:help -> Print current help' />
38
- <echo msg =' - db:backup -> Backup current database to a .sql file' />
39
- <echo msg =' - db:restore -> Restore currently backuped database' />
40
- <echo msg =' - db:execute -> Execute a query inside the current database' />
41
- <echo msg =' - db:details -> Show current configuration' />
42
- </target >
35
+ <target name =" db:help" depends =" db:check-configuration" description =" Print help for current phing command" >
36
+ <echo msg =" Specific database commands:" />
37
+ <echo msg =' - db:help -> Print current help' />
38
+ <echo msg =' - db:backup -> Backup current database to a .sql file' />
39
+ <echo msg =' - db:restore -> Restore currently backuped database' />
40
+ <echo msg =' - db:execute -> Execute a query inside the current database' />
41
+ <echo msg =' - db:details -> Show current configuration' />
42
+ </target >
43
43
<!-- ################################################################################-->
44
- <target name =" db:details" depends =" db:check-configuration" description =" Show current configuration" >
45
- <echo msg =" These are current db variables:" />
46
- <echo msg =' Credentials:' />
47
- <echo msg =' - db.user -> ${db.user}' />
48
- <echo msg =' - db.pass -> ${db.pass}' />
49
- <echo msg =' - db.name -> ${db.name}' />
50
- <echo msg =' - db.host -> ${db.host}' />
51
- <echo msg =' ' />
52
- <echo msg =' Configuration:' />
53
- <echo msg =' - db.charset -> ${db.charset}' />
54
- <echo msg =' - db.prefix -> ${db.prefix}' />
55
- <echo msg =' - db.collate -> ${db.collate}' />
56
- <echo msg =' ' />
57
- <echo msg =' Programs path:' />
58
- <echo msg =' - db.program.mysql -> ${db.program.mysql}' />
59
- <echo msg =' - db.program.mysqldump -> ${db.program.mysqldump}' />
60
- <echo msg =' ' />
61
- <echo msg =' Backup and restore file:' />
62
- <echo msg =' - db.path.backupfolder -> ${db.path.backupfolder}' />
63
- <echo msg =' - db.path.backupfile -> ${db.path.backupfile}' />
64
- </target >
44
+ <target name =" db:details" depends =" db:check-configuration" description =" Show current configuration" >
45
+ <echo msg =" These are current db variables:" />
46
+ <echo msg =' Credentials:' />
47
+ <echo msg =' - db.user -> ${db.user}' />
48
+ <echo msg =' - db.pass -> ${db.pass}' />
49
+ <echo msg =' - db.name -> ${db.name}' />
50
+ <echo msg =' - db.host -> ${db.host}' />
51
+ <echo msg =' ' />
52
+ <echo msg =' Configuration:' />
53
+ <echo msg =' - db.charset -> ${db.charset}' />
54
+ <echo msg =' - db.prefix -> ${db.prefix}' />
55
+ <echo msg =' - db.collate -> ${db.collate}' />
56
+ <echo msg =' ' />
57
+ <echo msg =' Programs path:' />
58
+ <echo msg =' - db.program.mysql -> ${db.program.mysql}' />
59
+ <echo msg =' - db.program.mysqldump -> ${db.program.mysqldump}' />
60
+ <echo msg =' ' />
61
+ <echo msg =' Backup and restore file:' />
62
+ <echo msg =' - db.path.backupfolder -> ${db.path.backupfolder}' />
63
+ <echo msg =' - db.path.backupfile -> ${db.path.backupfile}' />
64
+ </target >
65
65
<!-- ################################################################################-->
66
- <target name =" db:backup" depends =" db:check-configuration" description =" Backup the current database inside a content archive" >
67
- <!-- If dump folder does not exists, add it -->
68
- <if >
69
- <not >
70
- <available file =" ${db.path.backupfolder}" type =" dir" property =" " />
71
- </not >
72
- <then >
73
- <fail message =" Database backup folder does not exists : ${db.path.backupfolder}" />
74
- </then >
75
- </if >
76
- <!-- Dump Current DB -->
77
- <exec command =" ${db.program.mysqldump} --delayed-insert --skip-extended-insert --host=${db.host} --user=${db.user} --password=${db.pass.cmd} ${db.name} --result-file=${db.path.backupfolder}/${db.path.backupfile}" />
78
- </target >
66
+ <target name =" db:backup" depends =" db:check-configuration" description =" Backup the current database inside a content archive" >
67
+ <!-- If dump folder does not exists, add it -->
68
+ <if >
69
+ <not >
70
+ <available file =" ${db.path.backupfolder}" type =" dir" property =" " />
71
+ </not >
72
+ <then >
73
+ <fail message =" Database backup folder does not exists : ${db.path.backupfolder}" />
74
+ </then >
75
+ </if >
76
+ <!-- Dump Current DB -->
77
+ <exec command =" ${db.program.mysqldump} --delayed-insert --skip-extended-insert --host=${db.host} --user=${db.user} --password=${db.pass.cmd} ${db.name} --result-file=${db.path.backupfolder}/${db.path.backupfile}" />
78
+ </target >
79
79
<!-- ################################################################################-->
80
- <target name =" db:restore" depends =" db:check-configuration,helper:secure-by-input" description =" Restore backuped database" >
81
- <exec command =' ${db.program.mysql} --user=${db.user} --password=${db.pass.cmd} --host=${db.host} --skip-column-names --silent --execute="SHOW TABLES LIKE \"${db.prefix}\";" ${db.name} | while read table; do ${db.program.mysql} --user=${db.user} --password=${db.pass.cmd} --host=${db.host} --execute="DROP TABLE $table;" ${db.name}; done' logoutput =" true" />
82
- <exec command =" ${db.program.mysql} --user=${db.user} --password=${db.pass.cmd} --host=${db.host} ${db.name} < ${db.path.backupfolder}/${db.path.backupfile}" logoutput =" true" />
83
- </target >
80
+ <target name =" db:restore" depends =" db:check-configuration,helper:secure-by-input" description =" Restore backuped database" >
81
+ <exec command =' ${db.program.mysql} --user=${db.user} --password=${db.pass.cmd} --host=${db.host} --skip-column-names --silent --execute="SHOW TABLES LIKE \"${db.prefix}\";" ${db.name} | while read table; do ${db.program.mysql} --user=${db.user} --password=${db.pass.cmd} --host=${db.host} --execute="DROP TABLE $table;" ${db.name}; done' logoutput =" true" />
82
+ <exec command =" ${db.program.mysql} --user=${db.user} --password=${db.pass.cmd} --host=${db.host} ${db.name} < ${db.path.backupfolder}/${db.path.backupfile}" logoutput =" true" />
83
+ </target >
84
84
<!-- ################################################################################-->
85
- <target name =" db:execute" depends =" db:check-configuration" description =" Execute a query in the current database" >
86
- <if >
87
- <isset property =" query" />
88
- <then >
89
- <exec command =' ${db.program.mysql} --user=${db.user} --password=${db.pass.cmd} --host=${db.host} --execute="${query};" ${db.name}' logoutput =" true" />
90
- </then >
91
- <else >
92
- <echo message =" You need to call this target with query parameter set" />
93
- </else >
94
- </if >
95
- </target >
96
- </project >
85
+ <target name =" db:execute" depends =" db:check-configuration" description =" Execute a query in the current database" >
86
+ <if >
87
+ <isset property =" query" />
88
+ <then >
89
+ <exec command =' ${db.program.mysql} --user=${db.user} --password=${db.pass.cmd} --host=${db.host} --execute="${query};" ${db.name}' logoutput =" true" />
90
+ </then >
91
+ <else >
92
+ <echo message =" You need to call this target with query parameter set" />
93
+ </else >
94
+ </if >
95
+ </target >
96
+ </project >
0 commit comments