31 мар. 2021 г.

Backup Asterisk configs and Databases to Yandex.Disk by cron task

wget http://repo.yandex.ru/yandex-disk/yandex-disk_latest_amd64.deb
dpkg -i yandex-disk_latest_amd64.deb
yandex-disk setup (set yandex account)
yandex-disk sync --exclude-dirs other,client,dirs,comma,separated
ls ~/Yandex.Disk
apt install p7zip-full

create script:
==============
#!/bin/bash
tar -c --recursion /etc/asterisk/* | 7z a -pPassWordForAESCrypt -si /root/Yandex.Disk/clientname/conf-`date +%Y-%m-%d-%H-%M`.7z
mysqldump -u MySqlUser -pMySqlPassword DataBaseName |7z a -pPassWordForAESCrypt -si /root/Yandex.Disk/clientname/db-`date +%Y-%m-%d-%H-%M`.sql.7z
tar -c --recursion /var/www/* | 7z a -pPassWordForAESCrypt -si /root/Yandex.Disk/clientname/www-`date +%Y-%m-%d-%H-%M`.7z
find /root/Yandex.Disk/clientname -name "*.7z" -mtime +30 -exec rm -f {} \;
yandex-disk sync --exclude-dirs other,client,dirs,comma,separated
==============

add script to cron (crontab -e)
for example - 3 times per week:

0 3 * * 1,3,5 /root/confbackup