import osimport timesource = ['C:\\py\\', 'C:\\work\\']target_dir = 'C:\\backup'today = target_dir + os.sep + time.strftime('%Y%m%d')now = time.strftime('%H%M%S')if not os.path.exists(today): os.mkdir(today) print('Successfully create directory', today)target = today + os.sep + now + '.rar'zip_command = 'C:\\"Program Files"\\WinRAR\\rar a {0} {1}'.format(target, ' '.join(source))print(zip_command)if os.system(zip_command) == 0: print('Successful backup.', target)else: print('Backup FAILED.')