Incremental BackUp tool written in Python
http://www.nongnu.org/rdiff-backup/
Win32에서 사용하기
백업하기
rdiff-backup TARGET_DIR BACKUP_DIR rdiff-backup --remove-older-than 10D BACKUP_DIR # 10일 지난 파일들 삭제 rdiff-backup -r 3D BACKUP_DIR WANTED_DIR # 원하는 경로에 3일전 데이터 복구
rdiff-bacup 과 django dump 를 이용한 백업 스크립트 backup.sh
rdiff-backup /usr/local/dsite /home/agrims_backup/file rdiff-backup --remove-older-than 30D /home/agrims_backup/file /usr/local/bin/python /usr/local/dsite/manage.py dumpdata > /home/agrims_backup/db/dump_`date '+%Y%m%d.json'` 2>&1 /usr/local/bin/python /home/agrims_backup/remove_older_than_30day.py /home/agrims_backup/db 2>&1
remove_older_than_30day.py
1 #!/usr/local/bin/python
2
3 import sys, os
4 from datetime import date, timedelta
5
6 target = sys.argv[1]
7 for d in os.listdir(target):
8 if d.startswith('dump_'):
9 year = int(d[5:9])
10 month = int(d[9:11])
11 day = int(d[11:13])
12 file_date = date(year,month,day)
13 if date.today() - file_date > timedelta(30):
14 os.remove(os.path.join(target, d))