Month: May 2019

Using rsync to create backup

rsync is mostly used to synchronize files between Internet servers, but this powerful tool also can be used to create local backup.

I have an external harddisk for backup. Instead just using copy command to save my computer file to the external harddisk I want to verify first if the file saved there is exactly the same I have in the computer. Case the files are different I want to save a newer version and rename the older version.

It is easy to do using rsync:

rsync --suffix="_`date +%Y.%m.%d.%H.%M`" -bacH localdirtobackup /media/user/external_harddisk/

If the file exist in the external harddisk, but its content is different then it will be renamed to filename_YEAR.month.day.Hour.Minute

It also could interesting to know when some file was corrupted in the computer or external harddisk, or if some virus is changing your files.

AER: Corrected error received: 0000:00:1d.6

I was getting these errors:

[ 1089.225561] pcieport 0000:00:1d.6: AER: Corrected error received: 0000:00:1d.6
[ 1089.225586] pcieport 0000:00:1d.6: PCIe Bus Error: severity=Corrected, type=Data Link Layer, (Transmitter ID)
[ 1089.225593] pcieport 0000:00:1d.6: device [8086:a336] error status/mask=00001000/00002000
[ 1089.225597] pcieport 0000:00:1d.6: [12] Timeout

Unfortunately these error are repeating too fast and avoiding other messages to be shown in the dmesg command.

The solution is easy, just add “pci=noaer” to GRUB_CMDLINE_LINUX_DEFAULT in the /etc/default/grub to include it on Linux kernel command line when grub boots Linux:

$ vi /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash pci=noaer”

$ sudo update-grub

The reboot and the above message will desappear

Source: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1521173

Windows 10 only see 2MB partition on USB Flash Drive

I created a boot disk using Ubuntu “startup” program to install Linux on other computer, it worked fine, but when I put the USB Flash Drive on my computer that is running Windows 10 it only show 2MB.

It happens because the boot disk has two partitions and Windows only see the FAT partition. Fortuntately I found an way to fix it:

C:\> diskpart
DISKPART> list disk
DISKPART> select disk 1 (make sure its the right one)
DISKPART> clean (if it complains about permission, just type clean again)

It removed the partitions, but now I need to create other partition:

DISKPART> create partition primary

Then after removing and inserting the disk I format it and everything worked fine.

Source: https://askubuntu.com/questions/586118/16gb-pen-drive-showing-2mb-space-after-formatting-on-windows-7

Testing Mozilla DeepSpeech

These are the steps to test deepspeech 0.4.1 on Linux Ubuntu 18.04:

Install libsox and fake it as libsox2:

$ sudo apt-get install libsox-dev

$ ln -s libsox.so.3.0.0 libsox.so.2

Record your voice:

$ rec -c 1 -r 16000 -b 16 recording.wav

Alternatively download the audio from google translator and convert to wav 16bit 16khz mono:

$ ffmpeg -i the_quick_fox_jump_over_the_lazy_dogs.mp3 -acodec pcm_s16le -ac 1 -ar 16000 recording.wav

Test it:

$ ./deepspeech --model ../deepspeech-0.4.1-models/models/output_graph.pbmm --alphabet ../deepspeech-0.4.1-models/models/alphabet.txt --lm ../deepspeech-0.4.1-models/models/lm.binary --trie ../deepspeech-0.4.1-models/models/trie --audio recording.wav
TensorFlow: v1.12.0-10-ge232881
DeepSpeech: v0.4.1-0-g0e40db6
the quick brown fox jump over the lazy dog

Using sed command to replace newlines

WordPress is always modificating their software to improve speed and try to bring good things to users. Unfortunately the Block editor is not a good these things, at least not for me.

Recently while editing my post about my list of musics ( https://acassis.wordpress.com/2008/10/22/msicas-mais-ouvidas/ ) it placed the new lines between Music (Musica) and Artist (Cantor).

Then it became:

Music: Blablabla

Artist: Blabla

Music: Blablabla2

Artist: Blabla2

I wanted to restore the old organization:

Music: Blablabla
Artist: Blabla

Music: Blablabla2
Artist: Blabla2

Instead editing it be hand I tried to use VIM text editor, but vim recognizes \n as \0. And although there are some other ways to get it working on vim, Ctrl+J etc didn’t work as expected.

Then I remembered that sed -i could do the trick:

I tested this idea:

sed -i 's/\n\nCantor/\nCantor/g' musics.txt

It didn’t work, then searching in the Internet I found this post:
http://www.benjiegillam.com/2011/09/using-sed-to-replace-newlines/

Then the command became:

sed -i ':a;N;$!ba;s/\n\nCantor/\nCantor/g' musicas.txt

Now the order was restored.