- Because the company changed the server service provider and the server was migrated to another service provider, today we will simulate the operation of online migration of gitlab
- git-A IP:192.168.82.184
- git-B IP:192.168.82.184
- If the version number is the same, the backup migration will fail
Step 1.gitlab backup gita-A
#create backup copy $ gitlab-rake gitlab:backup:create STRATEGY=copy 2020-03-31 04:17:23 -0400 -- Dumping database ... Dumping PostgreSQL database gitlabhq_production ... [DONE] 2020-03-31 04:17:27 -0400 -- done 2020-03-31 04:17:27 -0400 -- Dumping repositories ... * root/tesporject (@hashed/6b/86/6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b) ... [SKIPPED] [SKIPPED] Wiki 2020-03-31 04:17:28 -0400 -- done 2020-03-31 04:17:28 -0400 -- Dumping uploads ... 2020-03-31 04:17:28 -0400 -- done 2020-03-31 04:17:28 -0400 -- Dumping builds ... 2020-03-31 04:17:28 -0400 -- done 2020-03-31 04:17:28 -0400 -- Dumping artifacts ... 2020-03-31 04:17:28 -0400 -- done 2020-03-31 04:17:28 -0400 -- Dumping pages ... 2020-03-31 04:17:28 -0400 -- done 2020-03-31 04:17:28 -0400 -- Dumping lfs objects ... 2020-03-31 04:17:28 -0400 -- done 2020-03-31 04:17:28 -0400 -- Dumping container registry images ... 2020-03-31 04:17:28 -0400 -- [DISABLED] Creating backup archive: 1585642648_2020_03_31_12.9.1_gitlab_backup.tar ... done Uploading backup archive to remote storage ... skipped Deleting tmp directories ... done done done done done done done done #Backup file path $ ll /var/opt/gitlab/backups total 160 -rw-------. 1 git git 163840 Mar 31 04:17 1585642648_2020_03_31_12.9.1_gitlab_backup.tar
Step 2. Copy git-A backup / var / opt / gitlab / backups / 1585642648 "2020" 03 "12.9.1" gitlab "backup.tar to git-B
$ scp /var/opt/gitlab/backups/1585642648_2020_03_31_12.9.1_gitlab_backup.tar root@193.168.82.185:/var/opt/gitlab/backups/
Step 3.gitlab recovery
Note: data connection service needs to be stopped before recovery
#git-B operation $ gitlab-ctl stop unicorn ok: down: unicorn: 0s, normally up $ gitlab-ctl stop sidekiq ok: down: sidekiq: 1s, normally up
1. Modify permission, 600 do not have permission to restore
$ ls -lh /var/opt/gitlab/backups/ total 160K -rw-------. 1 root root 160K Mar 31 04:17 1585642648_2020_03_31_12.9.1_gitlab_backup.tar $ chmod 777 /var/opt/gitlab/backups/1585642648_2020_03_31_12.9.1_gitlab_backup.tar
2. recovery
Note: you will need to enter yes twice
$ gitlab-rake gitlab:backup:restore BACKUP=1585642648_2020_03_31_12.9.1 This task will now rebuild the authorized_keys file. You will lose any data stored in the authorized_keys file. Do you want to continue (yes/no)? yes Warning: Your gitlab.rb and gitlab-secrets.json files contain sensitive data and are not included in this backup. You will need to restore these files manually. Restore task is done.
3. Restart gitlab
$ gitlab-ctl start unicorn $ gitlab-ctl start sidekiq
4. Visit git-a & git-b
Note: before git-A makes backup, it creates a project testprojects. The backup is the same as git-B data