配置文件备份

2015-11-19 0 571
配置文件备份
#!/usr/bin/python
#Author:gdlinjianying@qq.com

import os
import time

source = ['/etc/sysconfig/network-scripts', '/etc/sysconfig/network', '/etc/resolv.conf']

target_dir = '/opt/'

target = target_dir + time.strftime('%Y%m%d%H%M%S' + '.tar.gz')

tar_command = "tar -czvf '%s' %s" % (target, ' '.join(source))

if os.system(tar_command) == 0:
	print '\nResult:'
	print 'Successful backup to', target
else:
	print '\nResult:'
	print 'Backup failed'

遇见资源网 python 配置文件备份 http://www.ox520.com/15981.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务