Commit Graph

92 Commits

Author SHA1 Message Date
Stan Hu c6ff77d4b8 Fix backup restore
Set permissions of backup dir to g+s

Closes #20188
2016-07-25 06:23:07 -07:00
Alejandro Rodríguez 86359ec854 Refactor repository paths handling to allow multiple git mount points 2016-06-29 22:30:31 -04:00
Stan Hu f03df22815 Only create the backup directory if it is local
Closes #12710
2016-06-10 10:17:54 -07:00
Connor Shea 903946c78a
Replace colorize gem with rainbow.
Colorize is a gem licensed under the GPLv2, so we can’t use it in GitLab without relicensing GitLab under the terms of the GPL. Rainbow is licensed under the MIT license and does the exact same thing as Colorize, so Rainbow was added in place of Colorize.

The syntax is slightly different for Rainbow vs. Colorize, and was updated in accordance.

The gem is still a dependency of Spinach, so it’s included in the development/test environments, but won’t be packaged with the actual product, and therefore doesn’t require we relicense the product.

An attempt at relicensing Colorize was made, but didn’t succeed as the library owner never responded.

Rainbow library: https://github.com/sickill/rainbow
Relevant issue regarding licensing in GitLab's gems: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/3775
2016-06-03 10:37:09 -06:00
Robert Speicher b826c9ff17 Create the specified remote directory during backup
This is idempotent, so there's no harm calling it if the directory
already exists.

Closes #12710
2016-05-31 13:29:37 -04:00
Kamil Trzcinski 718fe268c4 Improve after review 2016-05-24 22:52:31 -05:00
Kamil Trzcinski 12bd781031 Fix backups if registry is disabled 2016-05-23 14:18:39 -05:00
Kamil Trzcinski 143cd58c39 Added backup of container registry 2016-05-16 17:25:38 -05:00
Jeroen Nijhof 897f18032a Make sure there is a connection before using ActiveRecord 2016-02-08 17:31:24 +01:00
Marin Jankovski 3cc2b48a82 Backup LFS objects same as any upload. 2015-11-19 10:43:45 +01:00
Marin Jankovski bf3c0aafaa USe reject. 2015-11-18 18:14:13 +01:00
Marin Jankovski f5e3d93c28 Check which folders and archives should be packed before passing to tar command. 2015-11-18 13:01:35 +01:00
Kamil Trzcinski d0e3e823a2 Implement Build Artifacts
- Offloads uploading to GitLab Workhorse
- Use /authorize request for fast uploading
- Added backup recipes for artifacts
- Support download acceleration using X-Sendfile
2015-11-10 12:51:50 +01:00
Robert Speicher d09d62b6b8 Replace all usages of `git` command with configurable binary path
Closes #3311
2015-11-03 17:11:09 -05:00
Robert Speicher 60c5b52ee9 Explicitly require backup/files 2015-11-02 15:04:43 -05:00
Jacob Vosmaer 58260a0327 Do no rely on basename of builds, uploads 2015-10-16 17:16:17 +02:00
Jacob Vosmaer 901f544578 Remove superfluous mkdir -p 2015-10-06 15:38:21 +02:00
Jacob Vosmaer 7d58489fd9 Remove unused variable 2015-10-06 15:22:08 +02:00
Jacob Vosmaer e789644783 Keep old path: db/database.sql.gz
Documentation elsewhere refers to this internal path, let's keep
it.
2015-10-06 15:21:15 +02:00
Jacob Vosmaer 7b71727c56 Remove old "files" tarball explicitly 2015-10-06 15:10:13 +02:00
Jacob Vosmaer 90ddf140b9 Reduce disk IO during SQL backup
By using light gzip compression we can save a lot of disk IO during
the backup.
2015-10-06 15:06:15 +02:00
Jacob Vosmaer d3734fbd89 Use tar for intermediate backup storage
During the backup we create an intermediate copy of two directories:
builds and uploads. Instead of creating many small files with 'cp
-r', we now use tar (and fast gzip) to create single intermediate
files. This saves on disk IO and disk space while creating a backup.
2015-10-06 14:43:19 +02:00
Paul Beattie 253d2320ab Add support for AWS S3 Server-Side Encryption support
This adds support for AWS S3 SSE with S3 managed keys, this means the
data is encrypted at rest and the encryption is handled transparently to
the end user as well as in the AWS Console. This is optional and not
required to make S3 uploads work.
2015-09-25 17:06:31 +01:00
Valery Sizov d7242054ba add pg_schema to backup config 2015-09-18 16:29:13 +03:00
Kamil Trzcinski 2f2b9f67c2 Fix backup tests 2015-09-16 00:06:41 +02:00
Kamil Trzcinski c9d914a392 Fix builds directory store 2015-09-15 22:53:38 +02:00
Kamil Trzcinski ed18e04bb3 Cleanup CI backup => migrate with GitLab 2015-09-15 20:14:21 +02:00
Jacob Vosmaer 4cd06867c7 Do not delete the SQL dump too early
The change in baa157926d broke backup
restore fucnctionality. This would not lead to data loss, but it
prevented the restore script from working. This bug exists only in
7.14.0 release candidate versions, not in 7.13.

Reported in https://github.com/gitlabhq/gitlabhq/issues/9571 .
2015-08-21 16:12:46 +02:00
Ted Strzalkowski 7430e7b5fc Workaround the warnings emitted by MySQL 5.6 regarding password on the
command line.
2015-08-12 07:51:24 -07:00
Dmitriy Zaporozhets b118f648cb Merge branch 'master' of github.com:gitlabhq/gitlabhq 2015-08-03 11:04:04 +02:00
Jacob Vosmaer baa157926d Stricter mkdir's in 'rake gitlab:backup:create' 2015-07-30 10:17:34 +02:00
Jacob Vosmaer c5aae30773 Set internal backup directory modes on create
This sidesteps problems with running 'chmod' on some CIFS mounts.
2015-07-29 11:18:55 +02:00
Jacob Vosmaer 0be6debb0b Merge branch 'master' of dev.gitlab.org:gitlab/gitlabhq into backup-archive-permissions 2015-07-27 11:22:35 +02:00
Jacob Vosmaer 346b074979 Don't stop if database.sql.gz already exists
The existing behavior of the backups is to overwrite whatever data
was still there in the scratch directories. This broke when we added
a 'gzip' step because 'gzip database.sql' will fail if 'database.sql.gz'
already exists. Doing 'rm -f database.sql.gz' before the 'gzip'
avoids this failure.
2015-07-21 10:37:27 +02:00
Dmitriy Zaporozhets b9452d7bcd Merge branch 'improve-postgres-restore-cleaning' into 'master'
Use native Postgres database cleaning during backup restore

We were using hacks to drop tables etc during a Postgres backup
restore. With this change, we let pg_dump insert the DROP TABLE
statements it needs at the start of the SQL dump.

See merge request !1891
2015-07-07 23:02:48 +00:00
Jacob Vosmaer 90ab5a59bb Use native Postgres database cleaning during backup restore
We were using hacks to drop tables etc during a Postgres backup
restore. With this change, we let pg_dump insert the DROP TABLE
statements it needs at the start of the SQL dump.
2015-07-07 15:34:06 +02:00
Jacob Vosmaer bb50b7fcd0 Allow custom backup archive permissions
This change helps system administrators who want to replicate
GitLab backup files without needing root permissions.
2015-07-06 18:43:17 +02:00
Kamil Trzcinski 69c659ebd3 Compress database backup 2015-07-06 17:14:17 +02:00
Dmitriy Zaporozhets 0214a21db5 Merge branch 'restore_uploads_fix' into 'master'
Avoid "cannot copy directory ... to itself" error on restore (on Docker?)

rake gitlab:backup:restore fails for me in my Docker-hosted Gitlab-CE instance; during the restore, any existing "uploads" directory is backed up by [this code](https://gitlab.com/gitlab-org/gitlab-ce/blob/833bc30/lib/backup/uploads.rb#L23) --

```ruby
    def backup_existing_uploads_dir
      timestamped_uploads_path = File.join(app_uploads_dir, '..', "uploads.#{Time.now.to_i}")
      if File.exists?(app_uploads_dir)
        FileUtils.mv(app_uploads_dir, timestamped_uploads_path)
      end
    end
```

When this executes for me, the ```FileUtils.mv``` parameters are "/home/git/gitlab/public/uploads" and "/home/git/gitlab/public/uploads/../uploads.1407019546"; an exception is raised, producing this double stacktrace:

```
ArgumentError: cannot copy directory /home/git/gitlab/public/uploads to itself /home/git/gitlab/public/uploads/../uploads.1407019546
/home/git/gitlab/lib/backup/uploads.rb:26:in `backup_existing_uploads_dir'
/home/git/gitlab/lib/backup/uploads.rb:18:in `restore'
/home/git/gitlab/lib/tasks/gitlab/backup.rake:73:in `block (4 levels) in <top (required)>'
/home/git/gitlab/lib/tasks/gitlab/backup.rake:30:in `block (3 levels) in <top (required)>'
Errno::EXDEV: Invalid cross-device link @ sys_fail2 - (/home/git/gitlab/public/uploads, /home/git/gitlab/public/uploads/../uploads.1407019546)
/home/git/gitlab/lib/backup/uploads.rb:26:in `backup_existing_uploads_dir'
/home/git/gitlab/lib/backup/uploads.rb:18:in `restore'
/home/git/gitlab/lib/tasks/gitlab/backup.rake:73:in `block (4 levels) in <top (required)>'
/home/git/gitlab/lib/tasks/gitlab/backup.rake:30:in `block (3 levels) in <top (required)>'
Tasks: TOP => gitlab:backup:uploads:restore
(See full trace by running task with --trace)
```

I'm guessing from the first message that ```mv``` walks the destination path to ensure that we're not moving the source into itself -- it doesn't get as far as interpreting the '..', but throws when it sees that the destination appears to start with the source path.

The second stacktrace I have no clue about - maybe it's AUFS- or Docker-related?

I attempted to reproduce this separately with the omnibus distribution in a fresh Ubuntu 14.04 install without Docker involved, and was unable to - backup and restore worked fine. I then tested my theory by FileUtils.expand_path-ing the destination in my own Docker setup code, and that made the problem go away, so that's what this merge request does.

(I'm using backups created and restored on gitlab-ce 7-1-stable, at facfec4b2; this is on Ubuntu 14.04 with Docker 1.1.1)

I know I'd look askance at a PR without tests for an unreproducable problem, but even if this is rejected, I'm submitting it anyway because maybe someone else will Google it and find it useful. I'm happy to do more work to improve this if you have suggestions.

See merge request !165
2015-06-22 09:52:42 +00:00
Jeroen Nijhof a7047569db use gitlab not gitlabci 2015-06-09 18:30:38 +02:00
Jeroen Nijhof bf7315cb13 update fog to 1.25.0 and add multipart upload support 2015-06-09 17:56:37 +02:00
Valery Sizov 67c83489ca ability to skip some items in backup 2015-04-02 15:37:50 +03:00
Vinnie Okada 0f78d92e4c Don't use chmod_R for backup tars
When creating backup tar files, only change permissions on the `db`,
`uploads`, and `repositories` directories, not their contents.
2015-03-28 08:38:48 -06:00
Vinnie Okada 083027fc84 Change directory when removing old backups 2015-03-24 20:47:11 -06:00
Dmitriy Zaporozhets aadd38dbb9 Merge branch 'backup-permissions' into 'master'
Change permissions on backup files - #2

Use more restrictive permissions for backup tar files and for the db, uploads, and repositories directories inside the tar files.  See #1894.  Now the backup task recursively `chmod`s the `db/`, `uploads/`, and `repositories/` folders with 0700 permissions, and the tar file is created as 0600.

This is a followup to !1703, which was reverted because it broke Rspec tests.  The test failures were due to the rake task changing directories and not changing back, which I fixed with this commit.

cc @sytse

See merge request !1716
2015-03-21 23:50:20 +00:00
Vinnie Okada 06aafb7364 Call chdir() with a block 2015-03-19 20:30:19 -06:00
Valery Sizov d411a9e4d8 backup repo with tar instead of git bundle 2015-03-19 14:36:02 +02:00
Vinnie Okada 61c06c5e1a Change permissions on backup files
Use more restrictive permissions for backup tar files and for the db,
uploads, and repositories directories inside the tar files.
2015-03-17 19:04:21 -06:00
Dmitriy Zaporozhets 3a324d9c6d Revert "Merge branch 'backup-permissions' into 'master'"
This reverts commit c42262b43b, reversing
changes made to c6586b1283.
2015-03-16 23:51:46 -07:00
Vinnie Okada 8587a29370 Change permissions on backup files
Use more restrictive permissions for backup tar files and for the db,
uploads, and repositories directories inside the tar files.
2015-03-15 13:14:30 -06:00