Git
Disaster recovery
Learn the disaster recovery flow.
What is disaster recovery?
Disaster recovery is a planned process for restoring a project after data loss or system failure. Repository backups, remote copies, and restoration procedures are parts of this plan.
Working repository
↓
Create backup
↓
Restore after failure
Relying on only one Git remote may not be sufficient. Critical projects should have independent and regular backups.
Backing up and restoring a Git repository
git clone --mirror creates a bare mirror copy of a repository, including its branches and tags. This copy can be stored in a separate location for backup purposes.
git clone --mirror https://example.com/project.git project-backup.git
git clone project-backup.git recovered-project
Before restoring, you should check the backup's integrity and freshness. After restoration, verify remote addresses and access permissions as well.
Exercise Restore a repository from a backup
Create a new working repository named recovered-project from the mirror backup named project-backup.git. Then change into the new repository directory, list its branches, and print a completion message.
Show example solution
git clone project-backup.git recovered-project
cd recovered-project
git branch -a
echo "Depo geri yükleme adımı tamamlandı."
Test yourself
-
You want to recover both commit history and repository files after a server failure. Which backup approach is more suitable?
- Copy only temporary files from the working directory
- Rely on a remote repository without backups
- Save only the latest commit message
- Back up the repository regularly to an independent location
Show answer
Back up the repository regularly to an independent location — Regular repository backups stored independently provide a recovery option in situations such as server failure.
-
Complete the mirror backup command
git clone ____ https://example.com/project.git project-backup.git
Show answer
git clone --mirror https://example.com/project.git project-backup.git
-
Disaster recovery components
- Disaster recovery
- Plan to restore a system after failure
- Backup
- Creating a separate copy of data
- Restore
- Recovering data from a backup
- Integrity check
- Verifying backup data consistency
Next lesson: Summary - Security