import os
import time
source=['/python','/root/mysql']
target_dir='/pythonbak'
target=target_dir+'/'+time.strftime('%Y%m%d%H%M%S')+'.zip'
zip_command="zip -qr '%s' %s"%(target, ' '.join(source))
if os.system(zip_command)==0:
print 'Successful backup to',target
else:
print 'Backup FAILED'
print target
print zip_command
import os
import time
source = ['/python', '/root/mysql']
target_dir='/pythonbak'
today=target_dir+'/'+time.strftime('%Y%m%d')
now=time.strftime('%H%M%S')
if not os.path.exists(today):
os.mkdir(today)
print 'Successfully created %s directory'%today
else:
print 'Directory %s already exist!'%today
target = today + os.sep + now + '.zip'
zip_command="zip -qr '%s' %s"%(target, ' '.join(source))
if os.system(zip_command)==0:
print 'Successful backup to',target
else:
print 'Backup FAILED'
import os
import time
source = ['/python', '/root/mysql']
target_dir='/pythonbak'
today=target_dir+'/'+time.strftime('%Y%m%d')
now=time.strftime('%H%M%S')
comment = raw_input('Enter a comment -->')
if len(comment)==0:
target=today+os.sep+now+'.zip'
else:
target=today+os.sep+now+comment.replace(' ','_')+'.zip'
if not os.path.exists(today):
os.mkdir(today)
print 'Successfully created %s directory'%today
else:
print 'Directory %s already exist!'%today
zip_command="zip -qr '%s' %s"%(target, ' '.join(source))
if os.system(zip_command)==0:
print 'Successful backup to',target
else:
print 'Backup FAILED'