Python实现linux下文件备份
2014-02-27 10:03
99 查看
#!/usr/bin/python #Filename: backup_ver2.py import os import time source = ['/home/user/public_html', '/home/angelo/Pictures'] target_dir = '/home/backup/' 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 directory', 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!'
相关文章推荐
- Python实现Windows和Linux之间互相传输文件(文件夹)的方法
- Debian下用samba实现windows与linux文件共享(同事的blog,拿来备份)
- 【python】一个备份把文件备份到邮箱的python实现
- linux中部署rsync实现文件远程备份及同步
- python-实现重要文件的备份
- python实现数通设备tftp备份配置文件示例
- Python实现备份文件实例
- Python实现简单的文件传输与MySQL备份的脚本分享
- linux中部署rsync实现文件远程备份及同步(centos x64 6.8)
- SCP实现Linux到Windows的文件数据备份
- Python实现网站文件的全备份和差异备份
- Python实现文件的全备份和差异备份
- linux 用expect脚本实现scp服务器之间的文件备份
- Linux:RSync实现文件备份同步图解及代码
- Linux(CentOS)挂载移动硬盘,实现文件拷贝、备份
- Python脚本实现windows下文件的备份
- Python实现简单的文件传输与MySQL备份的脚本分享
- 用python编写脚本实现备份文件
- Python在Windows下实现文件备份 脚本程序 版本1
- Python学习之pyinotify监控Linux下文件,并实现邮件报警