RAR in Linux

VERSION=6.0.1
wget -qO- https://www.rarlab.com/rar/rarlinux-x64-${VERSION}.tar.gz | tar -xz
cd rar

sudo mv rar unrar /usr/local/bin
sudo mv rarfiles.lst /etc

wget -O rarreg.key https://pastebin.com/raw/Ed7iQSPm
sudo mv default.sfx rarreg.key /usr/local/lib

cd ..
rm -r rar
exec bash

Examples

# WordPress files backup
# Archive directory using tar and compress using rar
tar --exclude="*/wp-content/cache/*" -cf - -C "/path/to/mywordpress" . | rar a -idq -si{mywordpress.tar} {mywordpress.rar}

# Extract backup
rar p -inul {mywordpress.rar} | tar -xf - -C "/path/to/directory"

====================
====================

# Dump database and compress
# mysqldump prints to STDOUT
# {-si} flag reads from STDIN
mysqldump -u {root} -p{password} {mydatabase} --single-transaction --skip-lock-tables --quick | rar a -idq -si{mydatabase.sql} {mydatabase.rar}

# Uncompress and restore
# mysql reads from STDIN
# {p} prints file to STDOUT
# {-inul} disable all messages (important)
rar p -inul {mydatabase.rar} | mysql -u {root} -p{password} {mydatabase}