Virtual Box – Automating OVA’s backups

#!/bin/bash
#jjest@donkey:~$ VBoxManage list vms
#”house-plex-new” {14c956f3-79a5-447d-a1a8-4bfe091d6bed}
#”house-nagios_1″ {6b219ce4-cdbc-49c8-b899-e1e61e64b096}
#”house-ftp” {d126abb8-927d-4066-b66a-c0d52abec7c2}

date=$(date “+%Y%m%d”)
backup_path=”/data/vms/vm-backups”
for vm in $(VBoxManage list vms | cut -d ‘”‘ -f 2); do
#CREATE DIR IF NOT EXISTS
if [[ ! -d “$backup_path/$vm” ]]; then
echo “Creating $backup_path/$vm”
mkdir “$backup_path/$vm”
fi

#SHUTDOWN IF RUNNING
running_vm=$(VBoxManage list runningvms | cut -d ‘”‘ -f 2 | grep “$vm”)
if [[ “$running_vm” == “$vm” ]]; then
echo “Powering off $vm…”
VBoxManage controlvm “$vm” poweroff
else
echo “$vm already powered off…”
fi

#EXPORT OVA
if [[ ! -e “$backup_path/$vm/$vm-$date.ova” ]]; then
echo “Exporting $vm…”
VBoxManage export “$vm” -o “$backup_path/$vm/$vm-$date.ova”
else
echo “$vm-$date.ova already exists!”
fi

#POWER ON VM
echo “Powering on $vm…”
VBoxManage startvm “$vm” –type headless
done

google drive linux cli client.

https://www.fossmint.com/grive2-google-drive-client-for-linux/

Storcli for Avago/LSI Raid controllers

sudo apt-get install alien

jjest@backupsrv:~$ alien /data/software/StoreCLI/storcli_all_os/Linux/storcli-1.19.04-1.noarch.rpm
Must run as root to convert to deb format (or you may use fakeroot).
jjest@backupsrv:~$ sudo alien /data/software/StoreCLI/storcli_all_os/Linux/storcli-1.19.04-1.noarch.rpm
Warning: Skipping conversion of scripts in package storcli: postinst postrm prerm
Warning: Use the –scripts parameter to include the scripts.
storcli_1.19.04-2_all.deb generated
jjest@backupsrv:~$ sudo dpkg -i storcli_1.19.04-2_all.deb
Selecting previously unselected package storcli.
(Reading database … 216694 files and directories currently installed.)
Preparing to unpack storcli_1.19.04-2_all.deb …
Unpacking storcli (1.19.04-2) …
Setting up storcli (1.19.04-2) …
jjest@backupsrv:~$ sudo ./check-array-status.sh
Disk all good!
jjest@backupsrv:~$ cat ./check-array-status.sh
#!/bin/bash
out=$(/opt/MegaRAID/storcli/storcli64 /c0 show all | grep -e ^252 | grep -v Onln)
lines=$(echo $out | wc -l);
if [[ -z “$lines” ]]; then
if [[ $lines -gt 2 || $lines -eq 2 ]]; then
echo $out
else
OK=1
fi
else
OK=1
fi

if [ $OK == “1” ]; then
echo “Disk all good!”
fi

Vsftpd: User unable to login.

Vsftpd: User unable to login.

Thu May 18 22:37:47 2017 [pid 6851] [reolink] FAIL LOGIN: Client “::ffff:192.168.0.120”
Thu May 18 22:37:51 2017 [pid 6860] CONNECT: Client “::ffff:192.168.0.118”
Thu May 18 22:37:53 2017 [pid 6859] [reolink] FAIL LOGIN: Client “::ffff:192.168.0.118”
Thu May 18 22:38:01 2017 [pid 6883] CONNECT: Client “::ffff:192.168.0.118”
Thu May 18 22:38:03 2017 [pid 6882] [reolink] FAIL LOGIN: Client “::ffff:192.168.0.118”

User must have valid shell.

reolink:x:1001:1001::/home/reolink:

Add /bin/bash

reolink:x:1001:1001::/home/reolink:/bin/bash

Done!

Samba: Can’t add new user

root@donkey:~# smbpasswd -a lukie
New SMB password:
Retype new SMB password:
Failed to add entry for user lukie.

root@donkey:~# echo $?
1

#NEED TO CREATE OS USER FIRST. TIED TOGETHER.
root@donkey:~# sudo useradd lukie

root@donkey:~# smbpasswd -a lukie
New SMB password:
Retype new SMB password:
Added user lukie.

#WORKS!

Ubuntu Single User Mode…I always forget

Atlantic.Net Cloud – How to enter single user mode for Ubuntu Atlantic.net Cloud servers

Duckdns Host Update Script.

jjest@jjest-pi3:~$ cat ./duckdns.sh
#!/bin/bash
mail_to=email@gmail.com
dns_host=”host.duckdns.org”
ip=$(curl https://wtfismyip.com/text 1>&2)
token=”xxxxxxxxxxxxxxxxxxxxxxxxx”
url=”https://www.duckdns.org/update?domains=${dns_host}&token=${token}&ip=$ip&verbose=true”
curl $url > out
out=$(grep -i “NOCHANGE” out)
if [[ $out != “NOCHANGE” ]]; then
msg=”DNS updated: $dns_host”
echo $msg
echo “DNS updated!” | mail -s “$msg” $mail_to
else
echo “DNS no change”
fi

PGP How To

jjest@canadark ~ $ pgp -e test.txt jjest

jjest@canadark ~ $ cat test.txt
jkjlk

jjest@canadark ~ $ cat test.txt.pgp
�
�wb�
Y��ⴳ����4sn����E4?�vr��ĻbO’�I’�sI�O6v�;��/bk?�#<ا��^�N�(�ϏK��O;\����`o�W>+ШF��s���R��I�yg7�w���d�5x�Kf����?o�s`�SY=��4���4�B
*�����NJeC��l�=ɩ��TxG}P<��\́���*������o�#m�����ET^�m��|� ��VsP�,g�^��ݓN�G���n��0�P���ѳ���tu�I�����+�l#"T��HcT������U0>ND�G�X����qV�5�[���c
�D��ت:��[��ӊ
�zH{��

jjest@canadark ~ $ scp .gnupg/pubring.gpg jjest@donkeyrobot.duckdns.org:~
jjest@donkeyrobot.duckdns.org’s password:
pubring.gpg 100% 1178 1.2KB/s 00:00

jjest@canadark ~ $ scp test.txt.pgp jjest@donkeyrobot.duckdns.org:~
jjest@donkeyrobot.duckdns.org’s password:
test.txt.pgp 100% 346 0.3KB/s 00:00

Generate pub key in plain text.

jjest@canadark ~ $ gpg –armor –export > pub.asc
jjest@canadark ~ $ cat pub.asc
—–BEGIN PGP PUBLIC KEY BLOCK—–
Version: GnuPG v1.4.11 (GNU/Linux)

mQENBFkA4QcBCACivyRC+xf93KFiPekRrTki0RpF2dFqdO26qDXnPbJ3/eHwxxe2
jRGwS+t/OEpKFJVgr2uewyYKlICKB8td/45hVREiYBODn/0RUm7xF1gRzkrrOeeE
EBM5q3w9SZgQCAWYCkDAzgrPpxpqiU9r5T9lpSTEJRO3VHShtlKhl/Ritz0XKhjy
j80GVyh4Wl2/lIcqpsTA/xWDYGUMBwDQNdPMXdAt+4+/4YI8v94kVydJWnfS6p+C
j1khbOjGJr0DpZUTLVYnJg/zPcUIj4ikEF0GedB8TPKTPorvwLoc41RLfpLczte+
dxlpRv8dLODbAxLtB5t22ON5wCpcyqpKPjQTABEBAAG0FGpqZXN0IDxqamVzdEB1
dy5lZHU+iQE3BBMBAgAiBQJZAOEHAhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIX
gAAKCRAA7w2ecvmVbdOQB/dSvlRqo3Eenbk6Ri+aSrHs1qeNTqL5S57+HEN0sCOy
T4dr9OHb9HSnP4o+xrwF7TmAgRtXpdWn40ggYWI02f+fefzNrsSyeGfkjU+ohVZj
5vRPMlgeXJA7hdMWF9kve6w6Jrbw2y8HbbWCfcVwLQSGy/bslyfj39H046MyDU69
w6NdwHioi382Sbzet3+qF345/WBOzNgQzaa/M/39qj+ckm3skJMDx6xljAERAoFB
x7sM53q20wnAf/2yWglGesYe0hlRItk4eJt/sgzQ2Hx787wCJuVl+h56MmBc/f9x
uI1LdN1bJ5Fse6TJEpgIvdKePfLtpOn1jfj465q8Uwu5AQ0EWQDhBwEIANcL0V0b
bX91bOyoBwn9j4BhCAQtHPFOJm/hk7zVYYCcAcRfAMMcsNBUdVXFjAP37mFjCmgm
mlhC9WWI1+QVsyya40YbuB86HMFiNPJwDtDWZ52JPVPzT3KH9nHFP+gHF+i36dFN
P……..
—–END PGP PUBLIC KEY BLOCK—–

Generate private key for client as well.

$ gpg –export-secret-keys > key.asc

Xfer pub key to client.

jest@canadark ~ $ scp pub.asc key.asc donkeyrobot.duckdns.org:~
jjest@donkeyrobot.duckdns.org’s password:
pub.asc

can also do this (not tested)

gpg –keyserver search.keyserver.net –send-key you@example.com

Import pub key to client.

jjest@donkey:~$ gpg –import pub.asc
gpg: key 72F9956D: public key “jjest” imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)

jjest@donkey:~$ gpg –import key.asc
gpg: key 72F9956D: secret key imported
gpg: key 72F9956D: “jjest” not changed
gpg: Total number processed: 1
gpg: unchanged: 1
gpg: secret keys read: 1
gpg: secret keys imported: 1

list keys

jjest@donkey:~$ gpg –list-keys
/home/jjest/.gnupg/pubring.gpg
——————————
pub 2048R/72F9956D 2017-04-26
uid jjest
sub 2048R/F50C59D3 2017-04-26

Decrypt & unpack file

jjest@donkey:~$ gpg test.txt.pgp
gpg: encrypted with 2048-bit RSA key, ID F50C59D3, created 2017-04-

jjest@donkey:~$ cat test.txt
jkjlk

Comcast vs Century Link (Seattle)

jjest@jjest-pi3:~$ speedtest-cli
Retrieving speedtest.net configuration…
Retrieving speedtest.net server list…
Testing from XFINITY (73.169.165.149)…
Selecting best server based on latency…
Hosted by SoftLayer Technologies, Inc. (Seattle, WA) [16.78 km]: 90.226 ms
Testing download speed………………………………….
Download: 66.17 Mbit/s
Testing upload speed…………………………………………..
Upload: 1.60 Mbit/s

Century Link Gigabit @ House

jjest@donkey:~$ speedtest-cli
Retrieving speedtest.net configuration…
Retrieving speedtest.net server list…
Testing from CenturyLink (174.24.231.76)…
Selecting best server based on latency…
Hosted by CenturyLink, Inc (Seattle, WA) [2.10 km]: 9.499 ms
Testing download speed………………………………….
Download: 646.79 Mbit/s
Testing upload speed…………………………………………..
Upload: 243.64 Mbit/s

Hardware vs Software RAID

Some basic tests between software and hardware raid. see below… cialis generico in contrassegno buy viagra cheap

Hardware RAID – 9260-8i
*/dev/sda1 is the RAID6 ARRAY

root@donkey:~# time sh -c “dd if=/dev/zero of=/data/testfile bs=100k count=1k && sync”
1024+0 records in
1024+0 records out
104857600 bytes (105 MB) copied, 0.102246 s, 1.0 GB/s hard sell evolution viagra salesman quotes comprar genericos do viagra

real 0m0.710s
user 0m0.000s
sys 0m0.112s

root@donkey:~# dd if=/dev/zero of=/data/test1.img bs=1G count=1 oflag=dsync
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB) copied, 3.37577 s, 318 MB/s buy viagra generic canada buy pink viagra

root@donkey:~# hdparm -tT /dev/sda1
/dev/sda1:
Timing cached reads: 4238 MB in 2.00 seconds = 2119.34 MB/sec
Timing buffered disk reads: 1334 MB in 3.00 seconds = 444.65 MB/sec acheter cialis 20 mg

Software RAID – MDADM
*RAID 5

root@backupsrv:~# time sh -c “dd if=/dev/zero of=/data/testfile bs=100k count=1k && sync”
1024+0 records in
1024+0 records out
104857600 bytes (105 MB) copied, 2.01138 s, 52.1 MB/s

real 0m3.378s
user 0m0.000s
sys 0m0.208s

root@backupsrv:~# dd if=/dev/zero of=/data/test1.img bs=1G count=1 oflag=dsync
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB) copied, 17.8867 s, 60.0 MB/s

root@backupsrv:~# hdparm -tT /dev/md127
/dev/md127:
Timing cached reads: 3736 MB in 2.00 seconds = 1867.94 MB/sec
Timing buffered disk reads: 1020 MB in 3.00 seconds = 339.57 MB/sec best generic viagra manufacturer 10mg or 20mg of cialis