← 返回命令列表

Linux command

gitlab-backup 命令

安全

权限或系统影响较大,执行前请核对目标。

常用示例

Create a full GitLab backup

sudo gitlab-backup create

Create a backup, skipping selected components

sudo gitlab-backup create SKIP=db,uploads,registry

Create an incremental backup

sudo gitlab-backup create INCREMENTAL=yes PREVIOUS_BACKUP=[backup_id]

Restore from a backup file

sudo gitlab-backup restore BACKUP=[timestamp_version]

Restore selected components only

sudo gitlab-backup restore BACKUP=[timestamp] SKIP=registry,uploads

说明

gitlab-backup creates and restores backups of a GitLab Omnibus or source installation. A backup bundles the database, Git repositories, uploads, CI artifacts, container registry, Pages content, and other components into a single tar archive named TIMESTAMP_VERSION_gitlab_backup.tar. Backups are written to the directory configured by gitlab_rails'backup_path' (default /var/opt/gitlab/backups). The configuration files (gitlab.rb, secrets.json) are not included and must be backed up separately.

参数

SKIP _components_
Comma-separated list of components to omit. Valid values: db, repositories, uploads, builds, artifacts, lfs, registry, pages, terraform_state, packages, ci_secure_files.
BACKUP _id_
Identifier (timestamp_version) of the backup to restore. Required for restore.
STRATEGY _value_
Use copy to copy data to a tmp dir before tarring (safer for active sites); default streams directly.
INCREMENTAL _yes_
Create an incremental backup (requires existing PREVIOUS_BACKUP).
PREVIOUS_BACKUP _id_
Backup ID to base the incremental backup on.
GITLAB_BACKUP_MAX_CONCURRENCY _N_
Maximum number of concurrent processes for repository backups.
GZIP_RSYNCABLE _yes_
Use gzip's --rsyncable mode so backups deduplicate efficiently with rsync.

FAQ

What is the gitlab-backup command used for?

gitlab-backup creates and restores backups of a GitLab Omnibus or source installation. A backup bundles the database, Git repositories, uploads, CI artifacts, container registry, Pages content, and other components into a single tar archive named TIMESTAMP_VERSION_gitlab_backup.tar. Backups are written to the directory configured by gitlab_rails'backup_path' (default /var/opt/gitlab/backups). The configuration files (gitlab.rb, secrets.json) are not included and must be backed up separately.

How do I run a basic gitlab-backup example?

Run `sudo gitlab-backup create` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does SKIP _components_ do in gitlab-backup?

Comma-separated list of components to omit. Valid values: db, repositories, uploads, builds, artifacts, lfs, registry, pages, terraform_state, packages, ci_secure_files.