找回密码
 立即注册

扫一扫,访问微社区

QQ登录

只需一步,快速开始

查看: 4986|回复: 2

[求助] 备份脚本问题

2

主题

2

帖子

32

积分

贫民

积分
32
御剑把酒听秋雨 发表于 2014-8-21 22:06:40 | 显示全部楼层 |阅读模式
这个问题困扰了好几天,网上各种招资料还是不成功,求好心人帮助。谢谢!!


  1. #!/usr/bin/python
  2. # Filename: backup_ver1.py

  3. import os
  4. import time

  5. # 1. The files and directories to be backed up are specified in a list
  6. source = ['E:\\aaaa']
  7. # If you are using windows ,use source = [r'C:\Documents',r'D:\Work'] or something like that

  8. # 2. The backup must be stored in a main backup directory
  9. target_dir = 'E:\\cccc\\' # Remember to change this to what you will be using

  10. # 3. The files are backed up into a zip file.
  11. # 4. The name of the zip archive is the current date and time
  12. target = target_dir + time.strftime('%Y%m%d%H%M%S') + '.zip'

  13. # 5. We use the zip command (in Unix/Linux) to put the files in a zip crchive
  14. zip_command = "winrar a '%s' %s" % (target,''.join(source))
  15. # Run the backup
  16. if os.system(zip_command) == 0:
  17.     print 'Successful backup to',target
  18. else:
  19.     print 'Backup FAILED'
复制代码

运行之后就是这样

运行之后就是这样
回复

使用道具 举报

4

主题

77

帖子

77

积分

版主

Rank: 7Rank: 7Rank: 7

积分
77

活跃会员热心会员默默耕耘优秀版主论坛元老

北极 发表于 2014-8-28 22:19:16 | 显示全部楼层
你哪里存在问题,光光是把代码贴过来,但是不知道你哪里出问题了,希望你描述清楚
回复 支持 反对

使用道具 举报

0

主题

4

帖子

28

积分

贫民

积分
28
burning 发表于 2014-11-6 17:42:56 | 显示全部楼层
  1. zip_command = "winrar a %s %s" % (target,''.join(source))
复制代码

把那个单引号去掉就行了
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表