April 2018


blog.udartsev.ru

MySQL backup and restoring database

Backup database

time mysqldump -u root -p database > /var/backups/restore_backup.sql

Backup config and data

mv /var/lib/mysql /tmp/backups/mysql-lib.bak
cp /etc/mysql/my.cnf /tmp/backups/my.cnf.bak

Purge library

sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean

Reinstall

sudo apt-get update
sudo apt-get install mysql-server

Restore config

cp /tmp/backups/my.cnf.bak /etc/mysql/my.cnf
sudo service mysql restart

Create database

mysql -u root -p
mysql> CREATE DATABASE database;

Restore backup

time mysql -u root -p database < /var/backups/restore_backup.sql

Getting data from RAW (CR2) File to JPG (Ubuntu/Linux)

If you want to get data (in JPG) from your RAW file in Ubuntu/Linux, do next:

1) Install exiftool in your Linux system:

sudo apt install exiftool

2) not necessary step: view your RAW file data:

exiftool -s2 -all -b -X -fXMP:XMP foto.cr2

3) not necessary step: near the bottom, it will shows:

Composite:PreviewImage='(Binary data 1706501 bytes, use -b option to extract)'
Composite:ThumbnailImage='(Binary data 17031 bytes, use -b option to extract)'

enter image description here

4) Use the "-b" option to extract either or both:

exiftool -Composite:PreviewImage -b foto.cr2 >preview.jpg
exiftool -Composite:ThumbnailImage -b foto.cr2 >thumb.jpg

5) To extract data from all files in the folder, do next:

for i in *.CR2; do exiftool -Composite:PreviewImage -b $i > $i.jpg; done

6) Done. We did execute all JPG data from RAW files: enter image description here


Image Magick Resize from Linux

How to resize your photos from Ubuntu (Lunux) console with ImageMagick?

for i in *.JPG; do convert -quality 100 -resize 30% $i $i; done

Для каждого $i в формате JPG > конвертируем в качество 100% + ресайз 30% от оригинала, перезаписываем файл $i в $i;

Получаем вместо 8mb фото, фото 1.2mb.