메인
차이
문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판이전 판다음 판 | 이전 판 | ||
| 메인 [2023/10/04 08:33] – kaishoo | 메인 [2026/09/28 03:00] (현재) – 211.169.22.222 | ||
|---|---|---|---|
| 줄 1: | 줄 1: | ||
| - | ======기상청 wiki====== | + | <htm |
| - | + | </ | |
| - | <code python BackupDokuWiki.py> | + | </body> |
| - | # -*- coding: cp949 -*- | + | </html> |
| - | from zipfile import ZipFile | + | {click-die}={screen says die} |
| - | from datetime import date | + | |
| - | import os | + | |
| - | + | ||
| - | # 도쿠위키를 ZIP 파일로 압축 | + | |
| - | def backup_dokuwiki(saveas): | + | |
| - | # root directory of dokuwiki | + | |
| - | DOKUWIKI_ROOT = ' | + | |
| - | + | ||
| - | # minimum list of backup | + | |
| - | # https:// | + | |
| - | DIRS_TO_BACKUP | + | |
| - | + | ||
| - | # | + | |
| - | with ZipFile(saveas, | + | |
| - | oldpath = os.getcwd() | + | |
| - | os.chdir(DOKUWIKI_ROOT) | + | |
| - | for dir in DIRS_TO_BACKUP: | + | |
| - | path = DOKUWIKI_ROOT + dir | + | |
| - | for dirpath, dirnames, filenames in os.walk(path): | + | |
| - | for filename in filenames: | + | |
| - | relpath = os.path.relpath(dirpath+'/' | + | |
| - | print relpath | + | |
| - | zf.write(relpath) | + | |
| - | os.chdir(oldpath) | + | |
| - | + | ||
| - | # 압축된 파일을 클라우드와 동기화 | + | |
| - | def moveto_cloud(filename): | + | |
| - | CLOUD_PATH = ' | + | |
| - | + | ||
| - | cloud_file = CLOUD_PATH+'/' | + | |
| - | + | ||
| - | if os.path.exists(cloud_file): | + | |
| - | os.remove(cloud_file) | + | |
| - | + | ||
| - | os.rename(filename, | + | |
| - | + | ||
| - | def main(argv): | + | |
| - | today | + | |
| - | filename = today.strftime(' | + | |
| - | + | ||
| - | backup_dokuwiki(filename) | + | |
| - | moveto_cloud(filename) | + | |
| - | + | ||
| - | return 0 | + | |
| - | + | ||
| - | if __name__ == ' | + | |
| - | import sys | + | |
| - | sys.exit(main(sys.argv)) | + | |
| - | </ | + | |