vendredi 27 février 2015

Combine the output of while loop into tar


I'm trying to create a script that mysqldumps all my databases, creating an individual .sql file for each database and combines the output into backup-DATE.tar.gz.


I've gotten as far as being able to create the .sql backups, but the last hump I can't overcome due to my limited knowledge is how to combine all the .sql files into backup-DATE.tar.gz.


This is what I have so far:



mysql -N -u user -p'password' -e 'show databases' | while read dbname; do mysqldump --add-drop-table -u user -p'password' "$dbname" > /backuplocation/"$dbname".sql; done


This outputs all my databases into my backup location individually ie:



/backuplocation/db1.sql
/backuplocation/db2.sql
/backuplocation/db3.sql


Is it possible to combine this output into backup-DATE.tar.gz with this strategy?



Disconnect of primary OpenLDAP freezes network


I am running two Ubuntu 12.04 LTS systems, one physical one virtual, configured as primary/secondary.



Physical - Primary LDAP, Secondary DNS/DHCP


Virtual - Secondary LDAP, Primary DNS/DHCP



I've noticed that if the physical server loses it's network connection clients on the network freeze (majority linux). The clients ARE ssh'd in to network servers and mounting NFS exports but shouldn't the secondary system take over or have I missed something.


Any ideas on what items I should look at or which configuration information would be helpful in diagnosing this?



hard drive formatted while Linux setup, lost partitions


I have installed Ubunto 14.04 on sda1. but after the installation finished, all the partitions are gone . I have important data on sda5 , and when I run the following command : sudo fdisk -l in the terminal the following appears :



Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x000cf11e

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 499711 248832 83 Linux
/dev/sda2 501758 976771071 488134657 5 Extended
Partition 2 does not start on physical sector boundary.
/dev/sda5 501760 976771071 488134656 8e Linux LVM

Disk /dev/mapper/ubuntu--vg-root: 495.6 GB, 495594766336 bytes 255
heads, 63 sectors/track, 60252 cylinders, total 967958528 sectors
Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical):
512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096
bytes Disk identifier: 0x00000000

Disk /dev/mapper/ubuntu--vg-root doesn't contain a valid partition
table

Disk /dev/mapper/ubuntu--vg-swap_1: 4202 MB, 4202692608 bytes 255
heads, 63 sectors/track, 510 cylinders, total 8208384 sectors Units =
sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512
bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/ubuntu--vg-swap_1 doesn't contain a valid partition
table


The total size of the hard drive is 5oo GB



Get information on tools/packages that are not installed


How can I get information about packages I have not installed (other than a web search)?


For example, imagine I am interested in iftop. If I do a web search I can find a wikipedia article and the man page, but how can I find information like that from the terminal without using a browser?



Saving from arecord on a raspberry pi across a network to a mac


I've currently got a usb mic plugged into a Raspberry Pi B+ and am using the following code to record data:



arecord --buffer-time=5000000 -D plughw:1,0 -f cd -t raw | lame -r - stream.mp3


I then serve the resulting stream.mp3 file on the pi using Python simplehttp and listen to the recorded data using mplayer on the command line.


I'd really like to skip the step of saving audio data on the pi if it can be helped. I've tried various attempts at piping the audio data using ssh and netcat to mplayer on my mac but have not figured how to do this. It's not important to me to encode the audio using lame; I'm simply doing that to save space and bandwidth.



CentOS install spanning 2 or more CDs


I have a custom CentOS install which used to fit on 1 CD. With recent additions, it takes up more space than can fit on 1 CD. Some of our customers have old systems that aren't DVD compatible so we have to distribute our product on an install CD which now needs to be 2 CDs. What is the easiest way to setup our install to span 2 CDs?? So far, I've discovered the .discinfo file which specifies how many install discs there are. For Example, CentOS 5.5:



1272587247.016243
Final
i386
1,2,3,4,5,6
CentOS/base
/home/buildcentos/CENTOS/5.5/en/i386/CentOS
CentOS/pixmaps


After the i386 line, the number of installation CDs is displayed. In this example, '1,2,3,4,5,6'. How does one decide what RPMs and such to put on other CDs when the install grows past 1 CD??



Values from two lists are not processing correctly within two nested loops


I am trying to pass some values contained in two lists to a simple echo within two nested for loops (the echo is used to look at what is generated inside the inner loop). But the results are not expected. I sure could use some guidance!


Using the bash shell. Here is the snippet:





a_list="0.05 0.10"
b_list="120.0 130.0"
c=44
x=555.0
for a in $a_list
do
for b in $b_list
do
echo $x $a $b $c
done
done




I expect this:



555.0 0.05 120.0 44
555.0 0.05 130.0 44
555.0 0.10 120.0 44
555.0 0.10 130.0 44


but I get this:



555.0 0.05 120.0 44
44.0 0.05 130.0
555.0 0.10 120.0 44
44.0 0.10 130.0


The 2nd and 4th lines are wrong. The 44 appears to echo first and overwrite the 555.0 . If I load the values of the lists directly into the for loop, it works OK. Like this:





c=44
x=555.0
for a in 0.05 0.10
do
for b in 120.0 130.0
do
echo $x $a $b $c
done
done


Thanks for any help and insights!