Recovering Deleted GitLab Projects: A Step-by-Step Guide
Did you accidentally delete a GitLab project and find yourself in a state of panic? Fear not! GitLab comes equipped with robust recovery functionalities. This guide will walk you through the steps to recover a deleted project, ensuring you're back on track in no time.
Before we delve into the recovery process, let's first understand that GitLab follows a trash management system. After deletion, projects reside in GitLab's trash for 30 days, providing a window for you to recover them. Now, let's bring your project back to life.
Understanding GitLab's Trash Management System
The first step in recovering a deleted project is to understand GitLab's trash management. Here's how it works:
When you delete a project, it doesn't vanish immediately. Instead, GitLab moves it to the trash, where it stays for 30 days. During this time, you can still access and recover the project. After the 30-day period, GitLab permanently deletes the project.
Recovering a Project from GitLab's Trash
Now that you understand GitLab's trash system, let's explore how to recover a deleted project. Follow these steps:
1. Log in to your GitLab account and navigate to your user dashboard.
2. Click on the 'Trash' icon in the left sidebar.
3. Find the deleted project in the list. By default, projects are sorted by deletion date.
4. Click on the 'Recover' button next to the project you want to restore.
5. A confirmation dialog will appear. Click 'Recover' again to proceed.
Recovering a Project via the API
If you're comfortable with APIs, you can also recover a project programmatically. Here's how:
1. Familiarize yourself with the GitLab API documentation for the Projects reclamation endpoint.
2. Use the project ID and a personal access token with the 'api' scope to send a DELETE request to /projects/{id}/reclaim.
3. If the request is successful, GitLab will restore the project.
Preventing Future Deletions: Adding an Access Restriction
Now that your project is back, it's wise to prevent such accidents from happening again. Here's how to restrict who can delete a project:
1. Navigate to your project's settings page.
2. Click on the 'Access restriction' tab.
3. Uncheck the 'Everyone with access can' box under 'Permissions' for the 'Delete project' option.
4. Click 'Save changes' to finalize the restriction.
Restricting Deletions to Project Owners Only
Another way to prevent unwanted deletions is to restrict this action to project owners only. Follow these steps:
1. In the 'Access restriction' tab, uncheck the 'Project members' box under 'Permissions' for the 'Delete project' option.
2. Ensure the ' 오른쪽' box is checked, allowing project owners to delete the project.
3. Click 'Save changes' to apply the restriction.
If you've followed these steps, you've successfully recovered your deleted project and implemented measures to prevent such incidents in the future. Always remember to double-check before deleting, and stay safe out there in GitLab's git-iverse!