Linux之本站docker环境下的GitLab备份的方法

  • A+
所属分类:Linux  Linux中级
摘要

由于本站制作的中文版GitLab Docker镜像是基于github上一个大神的基础上改的,所以备份方面是一样一样的,今天特此记录下备份方法

利用docker-compose备份的方法

[root@DS-VM-Node59 ~]# docker stop gitlab_server && docker rm gitlab_server #备份之前需要停止gitlab和删除
[root@DS-VM-Node59 ~]# docker-compose -f /data/docker-compose.yml run --rm gitlab app:rake gitlab:backup:create

利用备份恢复的方法

docker-compose run --rm gitlab app:rake gitlab:backup:restore #列出可用备份版本
docker-compose run --rm gitlab app:rake gitlab:backup:restore BACKUP=1417624827 # 指定恢复到版本1417624827
[root@DS-VM-Node59 ~]# docker-compose -f /data/docker-compose.yml run --rm gitlab app:rake gitlab:backup:create 
Initializing logdir...
Initializing datadir...
Installing configuration templates...
Configuring gitlab...
Configuring gitlab::database
Configuring gitlab::redis
Configuring gitlab::secrets...
Configuring gitlab::sidekiq...
Configuring gitlab::gitlab-workhorse...
Configuring gitlab::unicorn...
Configuring gitlab::timezone...
Configuring gitlab::rack_attack...
Configuring gitlab::ci...
Configuring gitlab::artifacts...
Configuring gitlab::lfs...
Configuring gitlab::project_features...
Configuring gitlab::oauth...
Configuring gitlab::ldap...
Configuring gitlab::backups...
Configuring gitlab::backups::schedule...
Configuring gitlab::registry...
Configuring gitlab-shell...
Configuring nginx...
Configuring nginx::gitlab...
Running raketask gitlab:backup:create...
Dumping database ... 
Dumping MySQL database gitlabhq_production ... [DONE]
done
Dumping repositories ...
 * Jay/pc ... [DONE]
 * Jay/pc.wiki ...  [SKIPPED]
 * lookback/docker-redis ... [DONE]
 * lookback/docker-redis.wiki ...  [SKIPPED]
 * xiaolin/dsf.wiki ...  [SKIPPED]
done
Dumping uploads ... 
done
Dumping builds ... 
done
Dumping artifacts ... 
done
Dumping lfs objects ... 
done
Dumping container registry images ... 
[DISABLED]
Creating backup archive: 1489614152_gitlab_backup.tar ... done
Uploading backup archive to remote storage  ... skipped
Deleting tmp directories ... done
done
done
done
done
done
done
Deleting old backups ... done. (0 removed)
[root@DS-VM-Node59 ~]# docker-compose -f /data/docker-compose.yml run --rm gitlab app:rake gitlab:backup:restore
Initializing logdir...
Initializing datadir...
Installing configuration templates...
Configuring gitlab...
Configuring gitlab::database
Configuring gitlab::redis
Configuring gitlab::secrets...
Configuring gitlab::sidekiq...
Configuring gitlab::gitlab-workhorse...
Configuring gitlab::unicorn...
Configuring gitlab::timezone...
Configuring gitlab::rack_attack...
Configuring gitlab::ci...
Configuring gitlab::artifacts...
Configuring gitlab::lfs...
Configuring gitlab::project_features...
Configuring gitlab::oauth...
Configuring gitlab::ldap...
Configuring gitlab::backups...
Configuring gitlab::backups::schedule...
Configuring gitlab::registry...
Configuring gitlab-shell...
Configuring nginx...
Configuring nginx::gitlab...

‣ 1489614152_gitlab_backup.tar (created at 16 Mar, 2017 - 05:42:32 CST)
‣ 1489613049_gitlab_backup.tar (created at 16 Mar, 2017 - 05:24:09 CST)

Select a backup to restore: ^C
Backup not specified. Exiting...
[root@DS-VM-Node59 ~]# ls -lh /data/gitlab-data/gitlab/backups/
总用量 2.6G
-rw------- 1 1000 1000 1.3G 3月  16 05:24 1489613049_gitlab_backup.tar
-rw------- 1 1000 1000 1.3G 3月  16 05:42 1489614152_gitlab_backup.tar
[root@DS-VM-Node59 ~]# 

Linux之本站docker环境下的GitLab备份的方法
注意此种自动备份是不支持备份SSH主机密钥的,SSH注解密钥是需要单独手动备份

lookback

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: