Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
9e6fc8b5
Commit
9e6fc8b5
authored
10 years ago
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Report failure of DB backup commands
parent
68590fdd
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
2 deletions
+16
-2
lib/backup/database.rb
lib/backup/database.rb
+16
-2
No files found.
lib/backup/database.rb
View file @
9e6fc8b5
...
@@ -11,23 +11,29 @@ module Backup
...
@@ -11,23 +11,29 @@ module Backup
end
end
def
dump
def
dump
case
config
[
"adapter"
]
success
=
case
config
[
"adapter"
]
when
/^mysql/
then
when
/^mysql/
then
print
"Dumping MySQL database
#{
config
[
'database'
]
}
... "
system
(
'mysqldump'
,
*
mysql_args
,
config
[
'database'
],
out:
db_file_name
)
system
(
'mysqldump'
,
*
mysql_args
,
config
[
'database'
],
out:
db_file_name
)
when
"postgresql"
then
when
"postgresql"
then
print
"Dumping PostgreSQL database
#{
config
[
'database'
]
}
... "
pg_env
pg_env
system
(
'pg_dump'
,
config
[
'database'
],
out:
db_file_name
)
system
(
'pg_dump'
,
config
[
'database'
],
out:
db_file_name
)
end
end
report_success
(
success
)
end
end
def
restore
def
restore
case
config
[
"adapter"
]
success
=
case
config
[
"adapter"
]
when
/^mysql/
then
when
/^mysql/
then
print
"Restoring MySQL database
#{
config
[
'database'
]
}
... "
system
(
'mysql'
,
*
mysql_args
,
config
[
'database'
],
in:
db_file_name
)
system
(
'mysql'
,
*
mysql_args
,
config
[
'database'
],
in:
db_file_name
)
when
"postgresql"
then
when
"postgresql"
then
print
"Restoring PostgreSQL database
#{
config
[
'database'
]
}
... "
pg_env
pg_env
system
(
'psql'
,
config
[
'database'
],
'-f'
,
db_file_name
)
system
(
'psql'
,
config
[
'database'
],
'-f'
,
db_file_name
)
end
end
report_success
(
success
)
end
end
protected
protected
...
@@ -54,5 +60,13 @@ module Backup
...
@@ -54,5 +60,13 @@ module Backup
ENV
[
'PGPORT'
]
=
config
[
"port"
].
to_s
if
config
[
"port"
]
ENV
[
'PGPORT'
]
=
config
[
"port"
].
to_s
if
config
[
"port"
]
ENV
[
'PGPASSWORD'
]
=
config
[
"password"
].
to_s
if
config
[
"password"
]
ENV
[
'PGPASSWORD'
]
=
config
[
"password"
].
to_s
if
config
[
"password"
]
end
end
def
report_success
(
success
)
if
success
puts
'[DONE]'
.
green
else
puts
'[FAILED]'
.
red
end
end
end
end
end
end
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment