Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitLab: Is the backup rake task atomic?

Tags:

gitlab

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?

like image 634
Alvin Avatar asked Apr 05 '13 04:04

Alvin


People also ask

What does GitLab Rake do?

GitLab provides Rake tasks to assist you with common administration and operational processes. You can perform GitLab Rake tasks by using: gitlab-rake <raketask> for Omnibus GitLab installations. bundle exec rake <raketask> for source installations.

Where does GitLab store backups?

All configuration for Omnibus GitLab is stored in /etc/gitlab . To backup your configuration, just run sudo gitlab-ctl backup-etc (introduced in GitLab 12.3). It creates a tar archive in /etc/gitlab/config_backup/ . Directory and backup files will be readable only to root.

Is GitLab backed up?

GitLab's built-in back up utility exports data created by users on your GitLab instance. This includes everything in the GitLab database and your on-disk Git repositories. Restoring the backup will reinstate your projects, groups, users, issues, uploaded file attachments, and CI/CD job logs.


1 Answers

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.

like image 121
VonC Avatar answered Nov 14 '22 16:11

VonC