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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
06aafb73
Commit
06aafb73
authored
Mar 19, 2015
by
Vinnie Okada
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Call chdir() with a block
parent
abbea9a0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
18 deletions
+17
-18
lib/backup/manager.rb
lib/backup/manager.rb
+17
-18
No files found.
lib/backup/manager.rb
View file @
06aafb73
...
@@ -11,28 +11,27 @@ module Backup
...
@@ -11,28 +11,27 @@ module Backup
s
[
:tar_version
]
=
tar_version
s
[
:tar_version
]
=
tar_version
tar_file
=
"
#{
s
[
:backup_created_at
].
to_i
}
_gitlab_backup.tar"
tar_file
=
"
#{
s
[
:backup_created_at
].
to_i
}
_gitlab_backup.tar"
orig_pwd
=
Dir
.
pwd
Dir
.
chdir
(
Gitlab
.
config
.
backup
.
path
)
do
Dir
.
chdir
(
Gitlab
.
config
.
backup
.
path
)
File
.
open
(
"
#{
Gitlab
.
config
.
backup
.
path
}
/backup_information.yml"
,
"w+"
)
do
|
file
|
file
<<
s
.
to_yaml
.
gsub
(
/^---\n/
,
''
)
end
File
.
open
(
"
#{
Gitlab
.
config
.
backup
.
path
}
/backup_information.yml"
,
"w+"
)
do
|
file
|
FileUtils
.
chmod_R
(
0700
,
%w{db uploads repositories}
)
file
<<
s
.
to_yaml
.
gsub
(
/^---\n/
,
''
)
end
FileUtils
.
chmod_R
(
0700
,
%w{db uploads repositories}
)
# create archive
$progress
.
print
"Creating backup archive:
#{
tar_file
}
... "
orig_umask
=
File
.
umask
(
0077
)
if
Kernel
.
system
(
'tar'
,
'-cf'
,
tar_file
,
*
BACKUP_CONTENTS
)
$progress
.
puts
"done"
.
green
else
puts
"creating archive
#{
tar_file
}
failed"
.
red
abort
'Backup failed'
end
File
.
umask
(
orig_umask
)
# create archive
upload
(
tar_file
)
$progress
.
print
"Creating backup archive:
#{
tar_file
}
... "
orig_umask
=
File
.
umask
(
0077
)
if
Kernel
.
system
(
'tar'
,
'-cf'
,
tar_file
,
*
BACKUP_CONTENTS
)
$progress
.
puts
"done"
.
green
else
puts
"creating archive
#{
tar_file
}
failed"
.
red
abort
'Backup failed'
end
end
File
.
umask
(
orig_umask
)
upload
(
tar_file
)
Dir
.
chdir
(
orig_pwd
)
end
end
def
upload
(
tar_file
)
def
upload
(
tar_file
)
...
...
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