日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

python备份文件代码_python备份文件以及mysql数据库的脚本代码

發布時間:2023/11/27 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python备份文件代码_python备份文件以及mysql数据库的脚本代码 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

#!/usr/local/python

import os

import time

import string

source=[‘/var/www/html/xxx1/‘,‘/var/www/html/xxx2/‘]

target_dir=‘/backup/‘

target=target_dir+time.strftime(‘%Y%m%d‘)

zip_comm=‘zip -r %s %s‘%(target," ".join(source))

target_database=[‘DB_name1‘,‘DB_name2‘]

sql_user=‘root‘

sql_pwd=‘xxx‘

if os.system(zip_comm) == 0:

print ‘file backup Success is:‘,target

#if python version is 3.x ,print(‘file backup Success is:‘,target)

else:

print ‘file backup failed!‘

for database_name in target_database:

target_sql=target_dir+database_name+time.strftime(‘%Y%m%d‘)+‘.sql‘

sql_comm=‘/usr/local/mysql/bin/mysqldump -u %s -p%s %s > %s‘%(sql_user,sql_pwd,database_name,target_sql)

if os.system(sql_comm) == 0:

print database_name,‘is backup seccess!‘

else:

print database_name,‘is backup Failed!!‘

原文:http://www.jb51.net/article/38264.htm

總結

以上是生活随笔為你收集整理的python备份文件代码_python备份文件以及mysql数据库的脚本代码的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。