Python remote backup script

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

#!/bin/python import os import sys import time import datetime import subprocess import smtplib from email.mime.text import MIMEText def mysqlBackup(): mysql_host = ‘localhost’ mysql_user = ‘root’ mysql_user_passwd = ‘password’ backup_path = ‘/mystuff/mysql_backup/’ dblist = [‘wordpress’] datetime = time.strftime(‘%m%d%Y-%H%M%S’) for db in dblist: backupdate = backup_path + db + “_” + datetime logger(“creating backup folder – ” […]

Read More

Example Of Capturing IOStat With Python

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

The below Example captures IOStat output with Python #!/bin/python import subprocess import csv io_c = subprocess.Popen([‘iostat’, ‘-xnsMr’, ‘1’, ‘2’], stdout=subprocess.PIPE, shell=False, stderr=subprocess.PIPE) stdout = io_c.communicate()[0] lc = len(stdout.split(‘\n’)) it_lc = lc / 2 + 2 reader = csv.reader(stdout.split(‘\n’)[it_lc:], delimiter=’,’) for row in reader: if any(row): #print row print row[0],row[1],row[2],row[3],row[7],row[8],row[9],row[10] Output would look like 0.0 0.0 […]

Read More