Auto backup something with python in freebsd system

来源:互联网 发布:马哥教育python 编辑:程序博客网 时间:2024/05/21 21:13
This program just to backup all apache22 in the freebsd system to a .tar.gz file with date.

source code:
#!/usr/bin/env python
 
import os
import datetime
today= datetime.date.today().isoformat()
cmdtar = "tar -C /usr/local/www/ -cvf /usr/home/sino/source_bakup/apache22_"+today+".tar apache22"
cmdgz = "gzip  /usr/home/sino/source_bakup/apache22_"+today+".tar"
print cmdtar
os.system(cmdtar)
print cmdgz
os.system(cmdgz)