docker gitlab backup & restore

docker상에서 운영중이 gitlab의 백업 및 리스토어 

#backup
[root@localhost ~]# docker ps -a
CONTAINER ID        IMAGE                     COMMAND             CREATED             STATUS                     PORTS                                                 NAMES
a336aa66475e        gitlab/gitlab-ce:latest   "/assets/wrapper"   6 hours ago         Exited (137) 6 hours ago                                                         gitlabgnoti
95013969775b        gitlab/gitlab-ce:latest   "/assets/wrapper"   29 hours ago        Up 6 hours (healthy)       443/tcp, 0.0.0.0:6015->22/tcp, 0.0.0.0:8897->80/tcp   gitlab
[root@localhost ~]# docker exec -i -t gitlab bash
[root@localhost ~]# docker exec -i -t gitlab bash
root@gitlab:/# gitlab-rake gitlab:backup:create
2019-09-18 12:32:59 +0000 -- Dumping database ...
Dumping PostgreSQL database gitlabhq_production ... [DONE]
2019-09-18 12:33:03 +0000 -- done
2019-09-18 12:33:03 +0000 -- Dumping repositories ...
 * gnoti/searchman (@hashed/d4/73/d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35) ... [DONE]
[SKIPPED] Wiki
 * gnoti/kupsiki (@hashed/4e/07/4e07408562bedb8b60ce05c1decfe3ad16b72230967de01f640b7e4729b49fce) ... [DONE]
[SKIPPED] Wiki
2019-09-18 12:33:07 +0000 -- done
2019-09-18 12:33:07 +0000 -- Dumping uploads ...
2019-09-18 12:33:07 +0000 -- done
2019-09-18 12:33:07 +0000 -- Dumping builds ...
2019-09-18 12:33:07 +0000 -- done
2019-09-18 12:33:07 +0000 -- Dumping artifacts ...
2019-09-18 12:33:07 +0000 -- done
2019-09-18 12:33:07 +0000 -- Dumping pages ...
2019-09-18 12:33:07 +0000 -- done
2019-09-18 12:33:07 +0000 -- Dumping lfs objects ...
2019-09-18 12:33:07 +0000 -- done
2019-09-18 12:33:07 +0000 -- Dumping container registry images ...
2019-09-18 12:33:07 +0000 -- [DISABLED]
Creating backup archive: 1568809987_2019_09_18_12.2.5_gitlab_backup.tar ... done
Uploading backup archive to remote storage  ... skipped
Deleting tmp directories ... done
done
done
done
done
done
done
done
Deleting old backups ... skipping
Warning: Your gitlab.rb and gitlab-secrets.json files contain sensitive data
and are not included in this backup. You will need these files to restore a backup.
Please back them up manually.
Backup task is done.
root@gitlab:/# ls /var/opt/gitlab/backups/
1568809987_2019_09_18_12.2.5_gitlab_backup.tar



#copy
[root@localhost ~]# docker cp gitlab:/var/opt/gitlab/backups/1568809987_2019_09_18_12.2.5_gitlab_backup.tar ./
[root@localhost ~]# scp *.tar root@192.168.0.169:/root/
root@192.168.0.169's password:
1568809987_2019_09_18_12.2.5_gitlab_backup.tar                                                                                                                                             100%   33MB  34.9MB/s   00:00


#restore
[root@localhost ~]# docker cp ./1568809987_2019_09_18_12.2.5_gitlab_backup.tar gitlab:/var/opt/gitlab/backups/
root@gitlab:/# gitlab-rake gitlab:backup:restore BACKUP=1568809987_2019_09_18_12.2.5
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

Deleting tmp directories ... done
done
done
done
done
done
done
done
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.



#restore
docker exec -i -t gitlab bash

gitlab-rake gitlab:backup:create

ls /var/opt/gitlab/backups/



docker cp gitlab:/var/opt/gitlab/backups/1568809318_2019_09_18_12.2.5_gitlab_backup.tar ./

scp *.tar root@192.168.0.169:/root/



docker cp ./1568809318_2019_09_18_12.2.5_gitlab_backup.tar gitlab:/var/opt/gitlab/backups/

docker exec -i -t gitlab bash

ls /var/opt/gitlab/backups/

gitlab-rake gitlab:backup:restore BACKUP=1568809987_2019_09_18_12.2.5




댓글

이 블로그의 인기 게시물

error You have $NVM_DIR set to "/root/.nvm", but that directory does not exist. Check your profile files and environment.

linux mint install xrdp

centos 6.x yum update problem making ssl connection