#!/usr/bin/env python3
import os
import time
def backup( sources, destination) :
os .makedirs ( destination, exist_ok= True )
archive = os .path .join ( destination, time .strftime ( '%Y%m%d_%H%M%S' ) + '.zip' )
zip_command = 'zip -qr {0} {1}' .format ( archive, ' ' .join ( sources) )
if os .system ( zip_command) :
print ( 'Backup creating failed.' )
else :
print ( 'Backup was successfully created in' , archive)
if __name__ == '__main__' :
sources = [
os .path .expanduser ( '~/work' ) ,
os .path .expanduser ( '~/Keepass2' ) ,
]
bkp_folder = os .path .expanduser ( '~/Backups' )
backup( sources, bkp_folder)
IyEvdXNyL2Jpbi9lbnYgcHl0aG9uMwoKaW1wb3J0IG9zCmltcG9ydCB0aW1lCgoKZGVmIGJhY2t1cChzb3VyY2VzLCBkZXN0aW5hdGlvbik6CiAgICBvcy5tYWtlZGlycyhkZXN0aW5hdGlvbiwgZXhpc3Rfb2s9VHJ1ZSkKCiAgICBhcmNoaXZlID0gb3MucGF0aC5qb2luKGRlc3RpbmF0aW9uLCB0aW1lLnN0cmZ0aW1lKCclWSVtJWRfJUglTSVTJykgKyAnLnppcCcpCgogICAgemlwX2NvbW1hbmQgPSAnemlwIC1xciB7MH0gezF9Jy5mb3JtYXQoYXJjaGl2ZSwgJyAnLmpvaW4oc291cmNlcykpCgogICAgaWYgb3Muc3lzdGVtKHppcF9jb21tYW5kKToKICAgICAgICBwcmludCgnQmFja3VwIGNyZWF0aW5nIGZhaWxlZC4nKQogICAgZWxzZToKICAgICAgICBwcmludCgnQmFja3VwIHdhcyBzdWNjZXNzZnVsbHkgY3JlYXRlZCBpbicsIGFyY2hpdmUpCgppZiBfX25hbWVfXyA9PSAnX19tYWluX18nOgogICAgc291cmNlcyA9IFsKICAgICAgICBvcy5wYXRoLmV4cGFuZHVzZXIoJ34vd29yaycpLAogICAgICAgIG9zLnBhdGguZXhwYW5kdXNlcignfi9LZWVwYXNzMicpLAogICAgXQogICAgYmtwX2ZvbGRlciA9IG9zLnBhdGguZXhwYW5kdXNlcignfi9CYWNrdXBzJykKICAgIGJhY2t1cChzb3VyY2VzLCBia3BfZm9sZGVyKQo=