사용자 도구

사이트 도구


git:as_backup

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
git:as_backup [2020/09/06 15:57]
kwon37xi
git:as_backup [2020/09/23 13:49] (현재)
kwon37xi
줄 1: 줄 1:
 ====== git as backup ====== ====== git as backup ======
   * [[:git|git]]을 백업도구로 사용하기   * [[:git|git]]을 백업도구로 사용하기
 +  * [[git:gitsync|gitsync]]
  
 ===== 특정 디렉토리 이하를 Git Repository로 백업할 때 ===== ===== 특정 디렉토리 이하를 Git Repository로 백업할 때 =====
줄 14: 줄 15:
 # 혹은 .gitattributes 에 * -text 항목 필요. 불필요한 줄끝형식 변환제거 # 혹은 .gitattributes 에 * -text 항목 필요. 불필요한 줄끝형식 변환제거
 git config core.autocrlf false git config core.autocrlf false
-git add /home/x/mydata+git config user.email "your@email.com" 
 +git config user.name "Git AutoBackup" 
 +# 필요하면 
 +git config  push.default simple
  
 +# 파일 추가하고 커밋&푸쉬
 +git add .
 +git commit -m 'backup initialized'
 +git branch -M main
 +git remote add origin <https://githost.com/path-to-git-backup.git>
 +git push -u origin main
 </code> </code>
 +
 +===== 주기적 백업을 수행할 shell script 생성 =====
 +  * ''backup.sh''
 +
 +<code sh>
 +NOWT=$(date +"%Y-%m-%d %T")
 +cd /path/to/workingdir
 +git add .
 +git commit -m "$NOWT Automated git push"
 +git push
 +</code>
 +  * commit 할게 없어도 오류 없이 무시된다.
 +
 +===== cron 등록 =====
 +  * 매일 새벽 4시 5분에 실행.
 +<code sh>
 +5 4 * * * /path/to/backup.sh > /tmp/cron_log.log 2>&1
 +</code>
 +
 +  * 로그를 계속 남기려면 로그 파일 리다이렉트를 ''%%>>%%'' 로 설정하고 [[linux:logrotate|logrotate]] 를 해준다.
  
 ===== 참조 ===== ===== 참조 =====
   * [[https://thearjunmdas.github.io/entries/backup-org-files-in-github/#code-snippet--back-up-file-to-github.sh|Backup org files in github :: ArMD — Architect Manager Devloper]]   * [[https://thearjunmdas.github.io/entries/backup-org-files-in-github/#code-snippet--back-up-file-to-github.sh|Backup org files in github :: ArMD — Architect Manager Devloper]]
  
git/as_backup.1599375473.txt.gz · 마지막으로 수정됨: 2020/09/06 15:57 저자 kwon37xi