最常用的备份手段自然是 tar 。不过 gitlab 数据目录实在太大了,要是直接运行 tar -czpf gitlab.tar.gz ./gitlab 不知道跑多久,也不知道有没有卡死。
于是上技术手段:用 pv 显示个进度条。
pv 项目的首页在 ivarch.com。下载 rpm 进行安装:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
[root@localhost ~]# rpm -ivh pv-1.6.20-1.x86_64.rpm
warning: pv-1.6.20-1.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 3fc56f51: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:pv-1.6.20-1.el6 ################################# [100%]
[root@localhost ~]# sudo tar cf - ./data -P | pv -s $(sudo du -sb ./data | awk '{print $1}') | gzip > gitlab.tar.gz
tar: ./data: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
du: cannot access ‘./data’: No such file or directory
pv: option requires an argument -- 's'
Try `pv --help' for more information.
[root@localhost ~]# cd gitlab
[root@localhost gitlab]# sudo tar cf - ./data -P | pv -s $(sudo du -sb ./data | awk '{print $1}') | gzip > gitlab.tar.gz
tar: ./data/gitlab-rails/sockets/gitlab.socket: socket ignored ] 6% ETA 0:01:52
tar: ./data/redis/redis.socket: socket ignored
tar: ./data/gitaly/internal_sockets/internal_364.sock: socket ignored
tar: ./data/gitaly/internal_sockets/internal_313.sock: socket ignored
tar: ./data/gitaly/internal_sockets/internal_321.sock: socket ignored
tar: ./data/gitaly/internal_sockets/internal_292.sock: socket ignored
tar: ./data/gitaly/internal_sockets/internal_289.sock: socket ignored
tar: ./data/gitaly/internal_sockets/internal_307.sock: socket ignored
tar: ./data/gitaly/internal_sockets/ruby.0: socket ignored
tar: ./data/gitaly/internal_sockets/ruby.1: socket ignored
tar: ./data/gitaly/gitaly.socket: socket ignored
tar: ./data/postgresql/.s.PGSQL.5432: socket ignored ] 18% ETA 0:01:43
tar: ./data/gitlab-workhorse/sockets/socket: socket ignored
tar: ./data/prometheus/data/wal/00003144: file changed as we read it ] 27% ETA 0:01:31
2.43GiB 0:01:14 [33.3MiB/s] [==================================================================>] 100%
|