Problem running the python code for backup on Ubuntu?

Posted by Akash on Ask Ubuntu See other posts from Ask Ubuntu or by Akash
Published on 2013-10-18T04:45:43Z Indexed on 2013/10/19 4:12 UTC
Read the original article Hit count: 268

Filed under:

I was trying to run following python code through terminal but something is wrong as it is producing some errors

source = ['/home/akash/', '/home/akash/code']
target_dir = '/media' 
target = target_dir + os.sep + time.strftime('%Y%m%d%H%M%S') + '.zip' 
zip_command = "zip -qr {0} {1}".format(target, ' '.join(source))
if os.system(zip_command) == 0:
    print('Successful backup to', target)
else:
    print('Backup FAILED')

but when i try to run it following error appears

zip I/O error: Permission denied
zip error: Could not create output file (/media/20131019083404.zip)
Backup FAILED

© Ask Ubuntu or respective owner

Related posts about python3