메인
차이
문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판이전 판다음 판 | 이전 판 | ||
| 메인 [2023/10/04 08:33] – kaishoo | 메인 [2024/05/29 04:28] (현재) – admin | ||
|---|---|---|---|
| 줄 1: | 줄 1: | ||
| - | ======기상청 wiki====== | + | < |
| - | + | < | |
| - | <code python BackupDokuWiki.py> | + | <div class=" |
| - | # -*- coding: cp949 -*- | + | <h1 class=" |
| - | from zipfile import ZipFile | + | <p class=" |
| - | from datetime import date | + | < |
| - | import os | + | < |
| - | + | | |
| - | # 도쿠위키를 ZIP 파일로 압축 | + | </p> |
| - | def backup_dokuwiki(saveas): | + | </div> |
| - | # root directory of dokuwiki | + | |
| - | DOKUWIKI_ROOT | + | </ |
| - | + | </html> | |
| - | # minimum list of backup | + | |
| - | # https://www.dokuwiki.org/ | + | |
| - | 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 = 'C:/Users/ | + | |
| - | + | ||
| - | 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)) | + | |
| - | </code> | + | |