CodeBlanks Logo Icon CodeBlanks

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.

Practice 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.

Starter code

terminal
# Ayna yedeğinden çalışma deposu oluştur
# Dalları listele ve tamamlanma mesajı yazdır

Sample solution

terminal
git clone project-backup.git recovered-project
cd recovered-project
git branch -a
echo "Depo geri yükleme adımı tamamlandı."

Expected output

Depo geri yükleme adımı tamamlandı.

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 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 Correct answer

Explanation: Regular repository backups stored independently provide a recovery option in situations such as server failure.

2 Complete the mirror backup command

Question
git clone ____ https://example.com/project.git project-backup.git
Answer
git clone --mirror https://example.com/project.git project-backup.git

Explanation: The <code>--mirror</code> option copies the remote repository's branches and references as a mirror.

3 Disaster recovery components

Term Meaning
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

All lessons in Expert