diff --git a/lib/backup/builds.rb b/lib/backup/builds.rb
index d269f8e260cf1af81f61d563dc2bf04c18a8ee23..800f30c21449b129640d04beae29b3b336ce7bce 100644
--- a/lib/backup/builds.rb
+++ b/lib/backup/builds.rb
@@ -1,7 +1,11 @@
 module Backup
   class Builds < Files
     def initialize
-      super(Settings.gitlab_ci.builds_path)
+      super('builds', Settings.gitlab_ci.builds_path)
+    end
+
+    def create_files_dir
+      Dir.mkdir(app_files_dir, 0700)
     end
   end
 end
diff --git a/lib/backup/files.rb b/lib/backup/files.rb
index 5a210a0e46446e48d7a9162668b8e69f66aefa87..654b4d1c8962dc35300e7590c90e3cdf88dc9baa 100644
--- a/lib/backup/files.rb
+++ b/lib/backup/files.rb
@@ -4,9 +4,9 @@ module Backup
   class Files
     attr_reader :name, :app_files_dir, :backup_tarball, :files_parent_dir
 
-    def initialize(app_files_dir)
+    def initialize(name, app_files_dir)
+      @name = name
       @app_files_dir = File.realpath(app_files_dir)
-      @name = File.basename(app_files_dir)
       @files_parent_dir = File.realpath(File.join(@app_files_dir, '..'))
       @backup_tarball = File.join(Gitlab.config.backup.path, name + '.tar.gz')
     end
@@ -15,13 +15,14 @@ module Backup
     def dump
       FileUtils.mkdir_p(Gitlab.config.backup.path)
       FileUtils.rm_f(backup_tarball)
-      run_pipeline!([%W(tar -C #{files_parent_dir} -cf - #{name}), %W(gzip -c -1)], out: [backup_tarball, 'w', 0600])
+      run_pipeline!([%W(tar -C #{app_files_dir} -cf - .), %W(gzip -c -1)], out: [backup_tarball, 'w', 0600])
     end
 
     def restore
       backup_existing_files_dir
+      create_files_dir
 
-      run_pipeline!([%W(gzip -cd), %W(tar -C #{files_parent_dir} -xf -)], in: backup_tarball)
+      run_pipeline!([%W(gzip -cd), %W(tar -C #{app_files_dir} -xf -)], in: backup_tarball)
     end
 
     def backup_existing_files_dir
diff --git a/lib/backup/uploads.rb b/lib/backup/uploads.rb
index 7c0838cc8b7b6627826d52ee61702e20ba5144cd..0a0ec564ba4f63db3ac6561cdc2def184fcb062c 100644
--- a/lib/backup/uploads.rb
+++ b/lib/backup/uploads.rb
@@ -2,7 +2,11 @@ module Backup
   class Uploads < Files
 
     def initialize
-      super(Rails.root.join('public/uploads'))
+      super('uploads', Rails.root.join('public/uploads'))
+    end
+
+    def create_files_dir
+      Dir.mkdir(app_files_dir)
     end
   end
 end