sudo apt update
sudo apt install git
ssh-keygen -t ed25519 -C "your_email@example.com"
cat ~/.ssh/id_ed25519.pub
생성된 공개키를 GitHub 계정 설정의 SSH keys 섹션에 추가합니다.
백업하려는 디렉토리 경로를 확인합니다. 예: /path/to/backup
cd /path/to/backup
git init
nano .gitignore
백업에서 제외할 파일이나 디렉토리를 추가합니다.
git remote add origin git@github.com:username/repository.git
git add .
git commit -m "Backup: $(date +"%Y-%m-%d %H:%M:%S")"
git push -u origin main
nano /path/to/backup_script.sh
스크립트 내용:
#!/bin/bash
cd /path/to/backup
git add .
git commit -m "Automated backup: $(date +"%Y-%m-%d %H:%M:%S")"
git push origin main
chmod +x /path/to/backup_script.sh
crontab -e
다음 줄을 추가하여 매일 자정에 백업 실행:
0 0 * * * /path/to/backup_script.sh
백업된 데이터를 복원해야 할 경우:
git clone git@github.com:username/repository.git /path/to/restore
이 매뉴얼을 따라 Ubuntu 서버의 특정 디렉토리를 GitHub에 백업할 수 있습니다. 정기적인 백업은 데이터 손실 방지와 버전 관리에 도움이 됩니다.