#Filename:backup_ver1
import os
import time
#1 Using list to specify the files and directory to be backed up
source = r'C:\Documents and Settings\rgolwalkar\Desktop\Desktop\Dr Py\Final_Py'
#2 define backup directory
destination = r'C:\Documents and Settings\rgolwalkar\Desktop\Desktop\PyDevResourse'
#3 Setting the backup name
targetBackup = destination + time.strftime('%Y%m%d%H%M%S') + '.rar'
rar_command = "rar.exe a -ag '%s' %s" % (targetBackup, ''.join(source))
##i am sure i am doing something wrong here - rar command please let me know
if os.system(rar_command) == 0:
print 'Successful backup to', targetBackup
else:
print 'Backup FAILED'
O/P:- Backup FAILED
WinRAR과뿐만 아니라 환경 변수에서 경로 및 CLASSPATH에 추가됩니다 디렉토리 - 디렉토리를 백업하기위한 제안과 다른 사람파이썬 스크립트는 백업
괜찮 았어. (tarfile 모듈을 가져 왔어.) 조용히 달렸다. 메시지를 생성하기 위해 아무것도 추가하지 않았기 때문에 나는 메시지를주지 않았다. 나는 목적지를 확인했다. = os.path.join (루트, Documents and Settings ","rgolwalkar ","Desktop ","Desktop ","PyDevResourse ") 그러나 백업이 없습니다. os.system (tar) == 0이면 : 'Successful backup to', targetBackup else : 'Backup FAILED'인쇄 - os.system (tar) == 1이면 오류가 발생합니다. : TypeError : system() 인수 1은 TarFile이 아닌 string이어야합니다. – rgolwalkar
궁금한데 왜 파이썬에 내장 된 zip과 같은 플랫폼이 아닌 rar를 사용하고 있습니까? –