Add new linux hdd
check ‘dmesg’ for new drive
create partition table with fdisk
format disk. 'mkfs -t ext3 /dev/hdc1‘
mount the drive 'mount -t ext3 /dev/sdc1 /mount/dir'
Uncategorized
check ‘dmesg’ for new drive
create partition table with fdisk
format disk. 'mkfs -t ext3 /dev/hdc1‘
mount the drive 'mount -t ext3 /dev/sdc1 /mount/dir'
Uncategorized
Usage: python ./scriptname.py oldword newword sourcfile.txt newfile.txt
#!/usr/local/bin/python
import os, sys
usage = "usage: %s search_text replace_text [infile [outfile]]” % os.path.basename(sys.argv[0])
if len(sys.argv) < 3:
print usage
else:
stext = sys.argv[1]
rtext = sys.argv[2]
input = sys.stdin
output = sys.stdout
if len(sys.argv) > 3:
input = open(sys.argv[3])
if len(sys.argv) > 4:
output = open(sys.argv[4], ‘w’)
for s in input.xreadlines():
output.write(s.replace(stext, rtext))
Shell script to send email notification if hdd status reaches certain threshold.
#!/bin/sh
Drives=`df | perl -e 'while(<>) { if((/9[5-9]%/ or /100%/) and not /\/dev\/sdb1/) { print$_; }}’` email=”email@email.com”
if [ "$Drives" ]; then
mail -s “[disk status] $HOSTNAME full” $email << EOM
$HOSTNAME is critically low on space. View df message below.
$Drives
EOM
fi
Uncategorized
Install iperf
apt-get install iperf
Listen on machine #1
$ iperf -s -P 2 -i 5 -p 5999 -f M
Send packets on machine #2
iperf -c backupserv -P 1 -i 5 -p 5999 -f M -t 60 -T 1
Results:
————————————————————
Client connecting to backupserv, TCP port 5999
TCP window size: 0.02 MByte (default)
————————————————————
[ 3] local 192.168.1.5 port 49711 connected with 192.168.1.3 port 5999
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 5.0 sec 562 MBytes 112 MBytes/sec
[ 3] 5.0-10.0 sec 562 MBytes 112 MBytes/sec
[ 3] 10.0-15.0 sec 561 MBytes 112 MBytes/sec
[ 3] 15.0-20.0 sec 561 MBytes 112 MBytes/sec
[ 3] 20.0-25.0 sec 562 MBytes 112 MBytes/sec
[ 3] 25.0-30.0 sec 561 MBytes 112 MBytes/sec
[ 3] 30.0-35.0 sec 561 MBytes 112 MBytes/sec
[ 3] 35.0-40.0 sec 561 MBytes 112 MBytes/sec
[ 3] 40.0-45.0 sec 561 MBytes 112 MBytes/sec
[ 3] 45.0-50.0 sec 561 MBytes 112 MBytes/sec
^C[ 3] 0.0-50.8 sec 5707 MBytes 112 MBytes/sec
sudo /sbin/ifconfig eth0:0 192.168.1.50 up
sudo /sbin/ifconfig eth0:0 192.168.1.50 down
dd if=/dev/zero bs=1M count=150 | bzip2 -c > 150mb.bz2
Run script in crontab for server backups, cuts down on number of lines in crontab and staggers rsync over time.
01 * * * * /path/to/file/backu_script.py
#!/usr/bin/python
import time
import os
current_hour=time.strftime("%H")
backup_user="pse_backup"
#element 0 = servername, element 1 = hour to backup
backup_time={'pse01':'10','pse02':'17'}
servers={'pse01':['/home','/var/log'], ‘pse02′:['/home','/var/log','/etc']}
for k, v in backup_time.iteritems():
hour = v
server = k
if hour == current_hour:
print server + ” is being backed up!”
for name, paths in servers.iteritems():
if server == name:
#Run Rsync cmd.
for path in paths:
os.system(”rsync -van -e ’ssh -i /home/pse_backup/.ssh/pse_backup_key’ “+backup_user+”@”+server+”:” + path + ” /data/backups/” + server + path)
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=finished.pdf file1.pdf file2.pdf