问题
If I make a GitLab backup using the gitlab:backup:create rake task just as someone is pushing to the repositories, will the backup process be affected?
Is it necessary to shutdown GitLab before doing the backup?
回答1:
The task gitlab/backup.rake itself doesn't look atomic.
It calls:
Rake::Task["gitlab:backup:db:create"].invoke
Rake::Task["gitlab:backup:repo:create"].invoke
That uses the gem activerecord:
puts "Dumping database tables ... ".blue
ActiveRecord::Base.connection.tables.each do |tbl|
...
Like other operations with ActiveRecord (see this question), it doesn't seem to be a global atomic operation.
Hold on, a few hours ago, randx (Dmitriy Zaporozhets), main developer for GitLab, just refactored the dumping a database:
- commit 38d23c0e5f816937047c9326f9dd33fb10490032 shows the use of the system call
mysqldump
:system("mysqldump #{mysql_args} #{config['database']} > #{db_file_name}")
- commit c33d5e16fe5f5dde4f270adaf7fb6fe5b9552018 add
GRANT SELECT, LOCK TABLES, ...
So the part dumping the database is now more atomic ;)
But the backup itself, which involves other steps including backing up the bare repos, is not atomic.
来源:https://stackoverflow.com/questions/15825735/gitlab-is-the-backup-rake-task-atomic