summaryrefslogtreecommitdiff
path: root/lib/backup
Commit message (Collapse)AuthorAgeFilesLines
* Stricter mkdir's in 'rake gitlab:backup:create'backup-directory-permissionsJacob Vosmaer2015-07-303-4/+14
|
* Set internal backup directory modes on createJacob Vosmaer2015-07-294-5/+3
| | | | This sidesteps problems with running 'chmod' on some CIFS mounts.
* Don't stop if database.sql.gz already existsoverwrite-during-backupJacob Vosmaer2015-07-211-0/+1
| | | | | | | | 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.
* Merge branch 'improve-postgres-restore-cleaning' into 'master' Dmitriy Zaporozhets2015-07-071-5/+2
|\ | | | | | | | | | | | | | | | | 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
| * Use native Postgres database cleaning during backup restoreJacob Vosmaer2015-07-071-5/+2
| | | | | | | | | | | | 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.
* | Compress database backupKamil Trzcinski2015-07-061-0/+14
|/
* Merge branch 'restore_uploads_fix' into 'master'Dmitriy Zaporozhets2015-06-221-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * Avoid "cannot copy directory to itself" restore errorBryan Stearns2014-08-031-1/+1
| |
* | use gitlab not gitlabciJeroen Nijhof2015-06-091-1/+1
| |
* | update fog to 1.25.0 and add multipart upload supportJeroen Nijhof2015-06-091-1/+2
| |
* | ability to skip some items in backupbackup_skip_optionValery Sizov2015-04-021-6/+36
| |
* | Don't use chmod_R for backup tarsVinnie Okada2015-03-281-1/+1
| | | | | | | | | | When creating backup tar files, only change permissions on the `db`, `uploads`, and `repositories` directories, not their contents.
* | Change directory when removing old backupsVinnie Okada2015-03-241-7/+8
| |
* | Merge branch 'backup-permissions' into 'master'Dmitriy Zaporozhets2015-03-211-18/+25
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * | Call chdir() with a blockVinnie Okada2015-03-191-18/+17
| | |
| * | Change permissions on backup filesVinnie Okada2015-03-171-5/+13
| | | | | | | | | | | | | | | Use more restrictive permissions for backup tar files and for the db, uploads, and repositories directories inside the tar files.
* | | backup repo with tar instead of git bundleValery Sizov2015-03-191-2/+3
|/ /
* | Revert "Merge branch 'backup-permissions' into 'master'"Dmitriy Zaporozhets2015-03-161-4/+0
| | | | | | | | | | This reverts commit c42262b43b009af990e5769840391862d64a1c2d, reversing changes made to c6586b1283a94c8f08bc669f4d8a9384b263073e.
* | Change permissions on backup filesVinnie Okada2015-03-151-0/+4
| | | | | | | | | | Use more restrictive permissions for backup tar files and for the db, uploads, and repositories directories inside the tar files.
* | Revert "Fix broken access control and refactor avatar upload"Dmitriy Zaporozhets2015-02-192-29/+13
| | | | | | | | This reverts commit 7d5f86f6cbd187e75a6ba164ad6bfd036977dd07.
* | Fix broken access control and refactor avatar uploadHannes Rosenögger2015-02-162-13/+29
| | | | | | | | | | | | | | | | | | | | | | This commit moves the note folder from /public/uploads/note to /uploads/note and changes the uploader accordingly. Now it's no longer possible to avoid the access control by modifing the url. The Avatar upload has been refactored to use an own uploader as well to cleanly seperate the two upload types.
* | Properly fix wiki restore.Achilleas Pipinellis2014-11-301-12/+14
| | | | | | | | | | | | ProjectWiki.new() creates a new wiki git repository, so any tries to bare clone a bundle fail. With this patch we remove the newly created wiki.git before restoring from the backup bundle.
* | Proper wiki restore. Fixes #845Achilleas Pipinellis2014-11-291-8/+12
| |
* | Add CRON=1 backup setting for quiet backupsJacob Vosmaer2014-11-203-38/+47
| |
* | Correctly restore empty repositories.Dimitry Andric2014-11-131-1/+7
| | | | | | | | | | | | If a project is being restored, but there is no bundle file, the project was empty when it was backed up. In this case, just use git init --base to create a new bare repository.
* | Merge remote-tracking branch 'origin/master' into backup_restore_drop_sequencesValery Sizov2014-11-121-1/+1
|\ \ | | | | | | | | | | | | Conflicts: CHANGELOG
| * | Factor using Repository#path_to_repoCiro Santilli2014-11-051-1/+1
| | |
* | | Drop all Postgres sequences during backup restoreJacob Vosmaer2014-10-281-0/+1
|/ /
* | Ask the wiki repo, not Gollum, if it's emptyJacob Vosmaer2014-10-201-1/+1
| | | | | | | | | | | | | | We need to skip empty repositories when creating a backup. Before this change, we were asking gollum-lib if the wiki contains any _pages_. Now we ask gitlab_git if the repository contains _files_. This should resolve gollum_lib Grit timeouts in the backup script.
* | Fail harder in the backup scriptJacob Vosmaer2014-10-013-6/+22
| | | | | | | | | | This change also shows the output of failed Git commands during the backup.
* | Add backup upload support to the rake taskJacob Vosmaer2014-09-291-2/+24
| |
* | Use create-hooks instead of rewrite-hooks.shJacob Vosmaer2014-09-081-1/+1
|/ | | | | The rewrite-hooks.sh script is a deprecated wrapper for gitlab-shell's create-hooks script.
* Backup wiki repo even if the main repo is emptyJacob Vosmaer2014-05-081-6/+3
| | | | | This fixes a bug where wiki repositories for projects with an empty main repository would not get backed up.
* Apply the locale encoding to `tar --version`Jacob Vosmaer2014-05-081-1/+1
| | | | | Fixes a bug with non-UTF8 locales introduced by 2b816075dc71dfe8f6f9e5349fdff7f03ad9dad0.
* Use ProjectWiki instead of GollumWiki in codeDmitriy Zaporozhets2014-04-091-2/+2
| | | | Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
* Drop all tables before restoring a PostgreSQL DBJacob Vosmaer2014-03-281-2/+3
| | | | | | Invoking 'db:schema:load' turned out to be a bad idea: when downgrading an existing GitLab installation, the schema of the newer version would be preserved when trying to import the old version.
* Replace backticks with Gitlab::PopenJacob Vosmaer2014-03-031-1/+6
|
* Merge branch 'backup_uploads_symlink' into 'master'Dmitriy Zaporozhets2014-03-011-2/+3
|\ | | | | | | Backup Uploads Symlink
| * Support symlinked public/uploads for backp restoreJacob Vosmaer2014-02-261-2/+3
| | | | | | | | | | | | | | The backup restore code moves any existing uploads directory out of the way before restoring the copy from the backup. If public/uploads was a symlink, this move would replace the symlink. This commit avoids this issue by first resolving any symlinks in the uploads path.
* | Use Gitlab::VERSION to version backupsJacob Vosmaer2014-02-271-16/+10
| | | | | | | | | | | | | | | | | | Previous to this commit, backups were tied to the git revision (SHA1) of the app at the time the backup:create command was invoked. If the SHA1 at the time of restore was different, the script would refuse to restore the backup. This commit loosens this tie so that the backup script only complains if the value of the Gitlab::VERSION constant is different between the time of backup and the time of restore.
* | Merge branch 'pg_force_restore' into 'master'Dmitriy Zaporozhets2014-02-271-0/+2
|\ \ | | | | | | | | | Pg Force Restore
| * | Empty the database during Postgres backup restoreJacob Vosmaer2014-02-261-0/+2
| |/ | | | | | | | | | | | | | | | | | | | | The expected behavior during a GitLab backup restore is to overwrite existing database data. This works for MySQL because the output of mysqldump contains 'DROP TABLE IF EXISTS' statements. pg_dump on the other hand assumes that one will restore into an empty database. When this is not the case, during the restore with psql some of the data will be skipped if existing data is 'in the way'. By first invoking `rake db:schema:load` during a Postgres GitLab backup restore, we make sure that all important data is correctly restored.
* | Use gitlab_shell.path to invoke rewrite-hooks.shJacob Vosmaer2014-02-261-2/+1
|/ | | | | | | The backup restore code for repositories was assuming that gitlab-shell is installed in /home/git/gitlab-shell. This commit changes that to use the configuration setting from gitlab.yml that specifies the path where gitlab-shell is installed.
* Report failure of DB backup commandsJacob Vosmaer2014-01-231-2/+16
|
* Remove duplication in Backup::ManagerJacob Vosmaer2013-11-061-2/+4
|
* Remove Bourne shell from backup codeJacob Vosmaer2013-11-064-15/+19
|
* Revert "More escaping"Dmitriy Zaporozhets2013-11-052-11/+9
| | | | This reverts commit c46eaca91247ccf8e6fb3b691dad028e1b084ae3.
* More escapingNigel Kukard2013-11-042-9/+11
| | | | | | | | | - Database name may contain characters which are not shell friendly - Database password could contain the same - While we at it there is no harm in escaping generated paths too - Refactored 2-line system(command) Signed-off-by: Nigel Kukard <nkukard@lbsd.net>
* Skip rather than fail empty wikis during backupJacob Vosmaer2013-10-101-1/+3
|
* move backup logic to lib. Fixed removing outdated backupsDmitriy Zaporozhets2013-08-051-0/+106
|