#!/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)
