Things change, roll with the punches.Oh, yeah. Go for it man, jump off the high dive, stare down the barrel of the gun, pee into the wind!
backup_ver2.py
上一篇 /
下一篇 2007-01-15 13:19:47
/ 个人分类:代码冢
#!/usr/bin/python
# Filename : backup_ver2.py
# backup and package /home/mushroom & /root directory
# to /root/backup/YearMonthDay/HourMinuteSecond.tar.gz
import os
import time
source = ['/home/mushroom/','/root/']
target_dir = '/root/backup/'
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 directory',today
target = today + os.sep + now + '.tar.gz'
zip_command = "tar zcvf '%s' %s" % (target,' '.join(source))
if os.system(zip_command) == 0:
print 'Successful backup to',target
else:
print 'Backup Failed'
收藏
举报
TAG:
代码冢
Python