环境:
Os:Centos 7
gitlab:17
1.执行备份命令
前提是gitlab要正常运行的状态下执行
[root@node1 ~]# gitlab-backup create 2025-03-21 02:45:08 UTC -- Dumping database ... 2025-03-21 02:45:08 UTC -- Dumping PostgreSQL database gitlabhq_production ... 2025-03-21 02:45:18 UTC -- [DONE] 2025-03-21 02:45:18 UTC -- Dumping database ... done 2025-03-21 02:45:18 UTC -- Dumping repositories ... {"command":"create","gl_project_path":"root/project_test","level":"info","msg":"started create","pid":4485,"relative_path":"@hashed/6b/86/6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b.git","storage_name":"default","time":"2025-03-21T02:45:19.296Z"} {"command":"create","gl_project_path":"root/project_test","level":"info","msg":"completed create","pid":4485,"relative_path":"@hashed/6b/86/6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b.git","storage_name":"default","time":"2025-03-21T02:45:19.792Z"} {"command":"create","gl_project_path":"root/project_test.wiki","level":"info","msg":"started create","pid":4485,"relative_path":"@hashed/6b/86/6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b.wiki.git","storage_name":"default","time":"2025-03-21T02:45:19.792Z"} {"command":"create","gl_project_path":"root/project_test.wiki","level":"info","msg":"completed create","pid":4485,"relative_path":"@hashed/6b/86/6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b.wiki.git","storage_name":"default","time":"2025-03-21T02:45:19.862Z"} 2025-03-21 02:45:19 UTC -- Dumping repositories ... done 2025-03-21 02:45:19 UTC -- Dumping uploads ... 2025-03-21 02:45:19 UTC -- Dumping uploads ... done 2025-03-21 02:45:19 UTC -- Dumping builds ... 2025-03-21 02:45:19 UTC -- Dumping builds ... done 2025-03-21 02:45:19 UTC -- Dumping artifacts ... 2025-03-21 02:45:19 UTC -- Dumping artifacts ... done 2025-03-21 02:45:19 UTC -- Dumping pages ... 2025-03-21 02:45:19 UTC -- Dumping pages ... done 2025-03-21 02:45:19 UTC -- Dumping lfs objects ... 2025-03-21 02:45:19 UTC -- Dumping lfs objects ... done 2025-03-21 02:45:19 UTC -- Dumping terraform states ... 2025-03-21 02:45:19 UTC -- Dumping terraform states ... done 2025-03-21 02:45:19 UTC -- Dumping container registry images ... [DISABLED] 2025-03-21 02:45:19 UTC -- Dumping packages ... 2025-03-21 02:45:19 UTC -- Dumping packages ... done 2025-03-21 02:45:19 UTC -- Dumping ci secure files ... 2025-03-21 02:45:20 UTC -- Dumping ci secure files ... done 2025-03-21 02:45:20 UTC -- Dumping external diffs ... 2025-03-21 02:45:20 UTC -- Dumping external diffs ... done 2025-03-21 02:45:20 UTC -- Creating backup archive: 1742525108_2025_03_21_17.1.1_gitlab_backup.tar ... 2025-03-21 02:45:20 UTC -- Creating backup archive: 1742525108_2025_03_21_17.1.1_gitlab_backup.tar ... done 2025-03-21 02:45:20 UTC -- Uploading backup archive to remote storage ... [SKIPPED] 2025-03-21 02:45:20 UTC -- Deleting old backups ... [SKIPPED] 2025-03-21 02:45:20 UTC -- Deleting tar staging files ... 2025-03-21 02:45:20 UTC -- Cleaning up /var/opt/gitlab/backups/backup_information.yml 2025-03-21 02:45:20 UTC -- Cleaning up /var/opt/gitlab/backups/db 2025-03-21 02:45:20 UTC -- Cleaning up /var/opt/gitlab/backups/repositories 2025-03-21 02:45:20 UTC -- Cleaning up /var/opt/gitlab/backups/uploads.tar.gz 2025-03-21 02:45:20 UTC -- Cleaning up /var/opt/gitlab/backups/builds.tar.gz 2025-03-21 02:45:20 UTC -- Cleaning up /var/opt/gitlab/backups/artifacts.tar.gz 2025-03-21 02:45:20 UTC -- Cleaning up /var/opt/gitlab/backups/pages.tar.gz 2025-03-21 02:45:20 UTC -- Cleaning up /var/opt/gitlab/backups/lfs.tar.gz 2025-03-21 02:45:20 UTC -- Cleaning up /var/opt/gitlab/backups/terraform_state.tar.gz 2025-03-21 02:45:20 UTC -- Cleaning up /var/opt/gitlab/backups/packages.tar.gz 2025-03-21 02:45:20 UTC -- Cleaning up /var/opt/gitlab/backups/ci_secure_files.tar.gz 2025-03-21 02:45:20 UTC -- Cleaning up /var/opt/gitlab/backups/external_diffs.tar.gz 2025-03-21 02:45:20 UTC -- Deleting tar staging files ... done 2025-03-21 02:45:20 UTC -- Deleting backups/tmp ... 2025-03-21 02:45:20 UTC -- Deleting backups/tmp ... done 2025-03-21 02:45:20 UTC -- 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. 2025-03-21 02:45:20 UTC -- Backup 1742525108_2025_03_21_17.1.1 is done. 2025-03-21 02:45:20 UTC -- Deleting backup and restore PID file ... done
2.查看备份文件
[root@node1 ~]# cd /var/opt/gitlab/backups [root@node1 backups]# ls 1742525108_2025_03_21_17.1.1_gitlab_backup.tar
3.指定备份名称备份
[root@node1 backups]#gitlab-backup create BACKUP=dump20250321[root@node1 backups]# ls -al total 524 drwx------ 2 git root 44 Mar 21 10:57 . drwxr-xr-x 21 root root 4096 Mar 19 17:23 .. -rw------- 1 git git 532480 Mar 21 10:57 dump20250321_gitlab_backup.tar [root@node1 backups]# pwd /var/opt/gitlab/backups
这个时候名字就以备份时的名称命名了