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
Léo-Paul Géneau
gitlab-ce
Commits
e2305519
Commit
e2305519
authored
Apr 10, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
backup/restore uploads
parent
1d03fa2e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
3 deletions
+46
-3
CHANGELOG
CHANGELOG
+2
-0
lib/backup/uploads.rb
lib/backup/uploads.rb
+25
-0
lib/tasks/gitlab/backup.rake
lib/tasks/gitlab/backup.rake
+19
-3
No files found.
CHANGELOG
View file @
e2305519
...
...
@@ -10,6 +10,8 @@ v 5.1.0
- Backup/Restore refactored. Backup dump project wiki too now
- Restyled Issues list. Show milestone version in issue row
- Restyled Merge Request list
- Backup now dump/restore uploads
- Improved perfomance of dashboard
v 5.0.0
- Replaced gitolite with gitlab-shell
...
...
lib/backup/uploads.rb
0 → 100644
View file @
e2305519
module
Backup
class
Uploads
attr_reader
:app_uploads_dir
,
:backup_uploads_dir
,
:backup_dir
def
initialize
@app_uploads_dir
=
Rails
.
root
.
join
(
'public'
,
'uploads'
)
@backup_dir
=
Gitlab
.
config
.
backup
.
path
@backup_uploads_dir
=
File
.
join
(
Gitlab
.
config
.
backup
.
path
,
'uploads'
)
end
# Copy uploads from public/uploads to backup/uploads
def
dump
FileUtils
.
mkdir_p
(
backup_uploads_dir
)
FileUtils
.
cp_r
(
app_uploads_dir
,
backup_dir
)
end
def
restore
if
File
.
exists?
(
app_uploads_dir
)
FileUtils
.
mv
(
app_uploads_dir
,
Rails
.
root
.
join
(
'public'
,
"uploads.
#{
Time
.
now
.
to_i
}
"
))
end
FileUtils
.
cp_r
(
backup_uploads_dir
,
app_uploads_dir
)
end
end
end
lib/tasks/gitlab/backup.rake
View file @
e2305519
...
...
@@ -9,6 +9,7 @@ namespace :gitlab do
Rake
::
Task
[
"gitlab:backup:db:create"
].
invoke
Rake
::
Task
[
"gitlab:backup:repo:create"
].
invoke
Rake
::
Task
[
"gitlab:backup:uploads:create"
].
invoke
Dir
.
chdir
(
Gitlab
.
config
.
backup
.
path
)
...
...
@@ -25,7 +26,7 @@ namespace :gitlab do
# create archive
print
"Creating backup archive:
#{
Time
.
now
.
to_i
}
_gitlab_backup.tar ... "
if
Kernel
.
system
(
"tar -cf
#{
Time
.
now
.
to_i
}
_gitlab_backup.tar repositories/ db/ backup_information.yml"
)
if
Kernel
.
system
(
"tar -cf
#{
Time
.
now
.
to_i
}
_gitlab_backup.tar repositories/ db/
uploads/
backup_information.yml"
)
puts
"done"
.
green
else
puts
"failed"
.
red
...
...
@@ -33,7 +34,7 @@ namespace :gitlab do
# cleanup: remove tmp files
print
"Deleting tmp directories ... "
if
Kernel
.
system
(
"rm -rf repositories/ db/ backup_information.yml"
)
if
Kernel
.
system
(
"rm -rf repositories/ db/
uploads/
backup_information.yml"
)
puts
"done"
.
green
else
puts
"failed"
.
red
...
...
@@ -99,10 +100,11 @@ namespace :gitlab do
Rake
::
Task
[
"gitlab:backup:db:restore"
].
invoke
Rake
::
Task
[
"gitlab:backup:repo:restore"
].
invoke
Rake
::
Task
[
"gitlab:backup:uploads:restore"
].
invoke
# cleanup: remove tmp files
print
"Deleting tmp directories ... "
if
Kernel
.
system
(
"rm -rf repositories/ db/ backup_information.yml"
)
if
Kernel
.
system
(
"rm -rf repositories/ db/
uploads/
backup_information.yml"
)
puts
"done"
.
green
else
puts
"failed"
.
red
...
...
@@ -136,5 +138,19 @@ namespace :gitlab do
puts
"done"
.
green
end
end
namespace
:uploads
do
task
:create
=>
:environment
do
puts
"Dumping uploads ... "
.
blue
Backup
::
Uploads
.
new
.
dump
puts
"done"
.
green
end
task
:restore
=>
:environment
do
puts
"Restoring uploads ... "
.
blue
Backup
::
Uploads
.
new
.
restore
puts
"done"
.
green
end
end
end
# namespace end: backup
end
# namespace end: gitlab
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