需求

  将重要文件备份到指定目录,存档文件名称为“当前日期.zip”。

前提

  1) Windows系统

  2) Python 3以上版本

旗舰版

 1 #!usr/bin/python
 2 # -*- coding:utf-8 -*-
 3 #Filename:backup_v1.py
 4 
 5 import os
 6 import time
 7 
 8 source = 'C:\\zzSource\\'
 9 target_dir = 'D:\\zzBackUp\\'
10 target = target_dir+time.strftime('%Y%m%d%H%M%S')+'.zip'
11 zip_command = "zip -qr %s %s"%(target,''.join(source))
12 print(zip_command)
13 print('---------------')
14 if os.system(zip_command)==0:
15     print('Successful backup to %s'%(target))
16 else:
17     print('Backup FAIILED')
backup_v1.py

相关文章:

  • 2021-11-27
  • 2021-11-14
  • 2021-11-25
  • 2021-11-22
  • 2021-07-16
  • 2022-12-23
  • 2022-12-23
  • 2021-08-29
猜你喜欢
  • 2021-11-10
  • 2021-12-21
  • 2022-12-23
  • 2021-04-03
  • 2021-07-24
  • 2022-02-02
相关资源
相似解决方案