fork download
  1.  
  2. source = ['~/python3']
  3.  
  4. target_dir = '~/backup' # Подставьте тот путь, который вы будете использовать.
  5.  
  6. today = target_dir + os.sep + time.strftime('%Y%m%d')
  7.  
  8. now = time.strftime('%H%M%S')
  9.  
  10. if not os.path.exists(today):
  11. os.mkdir(today)
  12. print('Каталог успешно создан', today)
  13.  
  14. target = today + os.sep + now + '.zip'
  15.  
  16. zip_command = "zip -qr {0} {1}".format(target, ' '.join(source))
  17.  
  18. if os.system(zip_command) == 0:
  19. print('Резервная копия успешно создана в', target)
  20. else:
  21. print('Создание резервной копии НЕ УДАЛОСЬ')
Runtime error #stdin #stdout #stderr 0.01s 28384KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 6, in <module>
NameError: name 'os' is not defined