[Python] shutil을 사용한 주기적 전체백업
2023. 12. 27. 15:32ㆍPYTHON
반응형
주기적으로 전체 백업을 진행할 일이 발생하여 shutil을 사용하여 백업을 진행해 보려한다.
매일 일단위 3회정도의 백업이 필요해 보여 처리를 진행한다.
폴더 구조는 그림과 같이 처리하였다.
실행은 그중에서 FolderCopy.py 파일을 사용한다.
import shutil
from UTIL.DateTimeUtil import *
class FolderCopyExecuteClass:
def __init__(self):
print(" _____ INIT _____")
self.DateTiemUtil = TimeUtilClass()
orgPath = "/mnt/www_php"
destPath = "/mnt/Z_AllBackUP/www_php/"
self.setCopy(orgPath, destPath)
def setCopy(self, orgPath, destPath):
try:
strDateTime = self.DateTiemUtil.getCurrentDateBunCho112()
# print(strDateTime)
destPath = destPath + f"{strDateTime}"
shutil.copytree(orgPath, destPath)
except Exception as e:
print(f" _____ setCopy ___ {e}")
if __name__ == "__main__":
FolderCopyExecuteClass()
crontab 을 사용하여 해당 내용을 주기적으로 처리하면 문제없이 진행될 듯 싶다.
'PYTHON' 카테고리의 다른 글
[Python] 을 이용한 pyautogui 사용방법 (0) | 2023.12.31 |
---|---|
[Python] 파이썬 네이버 API 뉴스 연동(2) (3) | 2023.12.31 |
[Python] 파이썬 네이버 API 뉴스 연동(1) (0) | 2023.12.31 |
[Python] 이미지파일의 한글 읽어오기(pytesseract) (1) | 2023.12.30 |
[Python] Pykrx를 통한 데이터 가져오기 (2) | 2023.12.25 |