One-step import
- Tier: Free, Premium, Ultimate
- Offering: GitLab Self-Managed
Use the one-step import method if you regularly run offline garbage collection. This method is a simpler operation compared to the three-step import method.
One-step import
The registry must be shut down or remain in read-only mode during the import.
Otherwise, data written during the import becomes inaccessible or leads to inconsistencies.
Ensure the database is disabled in the
registry['database']section of your/etc/gitlab/gitlab.rbfile:registry['database'] = { 'enabled' => false, # Must be false! }Ensure the registry is set to
read-onlymode.Edit your
/etc/gitlab/gitlab.rband add themaintenancesection to theregistry['storage']configuration. For example, for agcsbackend registry using ags://my-company-container-registrybucket, the configuration could be:## Object Storage - Container Registry registry['storage'] = { 'gcs' => { 'bucket' => '<my-company-container-registry>', 'chunksize' => 5242880 }, 'maintenance' => { 'readonly' => { 'enabled' => true # Must be set to true. } } }Save the file and reconfigure GitLab.
Run the following command:
sudo -u registry gitlab-ctl registry-database import --log-to-stdoutIf the command completed successfully, the registry is fully imported. You can enable the database, turn off read-only mode in the configuration, and start the registry service:
registry['database'] = { 'enabled' => true, # Must be enabled now! } ## Object Storage - Container Registry registry['storage'] = { 'gcs' => { 'bucket' => '<my-company-container-registry>', 'chunksize' => 5242880 }, 'maintenance' => { 'readonly' => { 'enabled' => false } } }Save the file and reconfigure GitLab.
Prerequisites:
- Create an external database.
Add the
databasesection to your/etc/gitlab/gitlab.rbfile, but start with the metadata database disabled:registry['database'] = { 'enabled' => false, # Must be false! 'host' => '<registry_database_host_placeholder_change_me>', 'port' => 5432, # Default, but set to the port of your database instance if it differs. 'user' => '<registry_database_username_placeholder_change_me>', 'password' => '<registry_database_placeholder_change_me>', 'dbname' => '<registry_database_name_placeholder_change_me>', 'sslmode' => 'require', # See the PostgreSQL documentation for additional information https://www.postgresql.org/docs/16/libpq-ssl.html. 'sslcert' => '</path/to/cert.pem>', 'sslkey' => '</path/to/private.key>', 'sslrootcert' => '</path/to/ca.pem>' }Ensure the registry is set to
read-onlymode.Edit your
/etc/gitlab/gitlab.rband add themaintenancesection to theregistry['storage']configuration. For example, for agcsbacked registry using ags://my-company-container-registrybucket, the configuration could be:## Object Storage - Container Registry registry['storage'] = { 'gcs' => { 'bucket' => '<my-company-container-registry>', 'chunksize' => 5242880 }, 'maintenance' => { 'readonly' => { 'enabled' => true # Must be set to true. } } }Save the file and reconfigure GitLab.
Apply database migrations if you have not done so.
Run the following command:
sudo gitlab-ctl registry-database importIf the command completed successfully, the registry is now fully imported. You can now enable the database, turn off read-only mode in the configuration, and start the registry service:
registry['database'] = { 'enabled' => true, # Must be enabled now! 'host' => '<registry_database_host_placeholder_change_me>', 'port' => 5432, # Default, but set to the port of your database instance if it differs. 'user' => '<registry_database_username_placeholder_change_me>', 'password' => '<registry_database_placeholder_change_me>', 'dbname' => '<registry_database_name_placeholder_change_me>', 'sslmode' => 'require', # See the PostgreSQL documentation for additional information https://www.postgresql.org/docs/16/libpq-ssl.html. 'sslcert' => '</path/to/cert.pem>', 'sslkey' => '</path/to/private.key>', 'sslrootcert' => '</path/to/ca.pem>' } ## Object Storage - Container Registry registry['storage'] = { 'gcs' => { 'bucket' => '<my-company-container-registry>', 'chunksize' => 5242880 }, 'maintenance' => { 'readonly' => { 'enabled' => false } } }Save the file and reconfigure GitLab.
You can now use the metadata database for all operations!