#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import time
source = ["./"] # 需要备份的目录
target_dir = "./code/" # 保存备份的目录
today_dir = target_dir + time.strftime('%Y%m%d')
time_dir = time.strftime("%H%M%S")
touch = today_dir + os.sep + time_dir + '.zip'
command_touch = "zip -qr " + touch + ' ' + ' '.join(source)
#逻辑思路判断
if not os.path.exists(today_dir):
os.mkdir(today_dir)
if os.system(command_touch) == 0:
print("Success backup Up")
else:
print("Failed backup")
python 文件备份
最新推荐文章于 2022-11-24 16:03:17 发布