Backup to Yandex Disk

    The script makes backup configuration Astra to Yandex.Disk service

    This script backup directories /etc/astra and file /usr/bin/astra to Yandex.Disk service

    Create a script

    #!/bin/sh
     
    TAR="$(which tar)"
    GZIP="$(which gzip)"
    FTP="$(which ftp)"
    NOW=$(date +%Y%m%d)
    mkdir /tmp/backuptmp
    mkdir /tmp/backuptmp/$NOW
    $TAR -cf /tmp/backuptmp/$NOW/etc_astra.tar /etc/astra
    $TAR -cf /tmp/backuptmp/$NOW/astra_bin.tar /usr/bin/astra
    ARCHIVE=/tmp/backuptmp/server-$NOW.tar.gz
    ARCHIVED=/tmp/backuptmp/$NOW
    $TAR -zcvf $ARCHIVE $ARCHIVED
    cd $BACKUP
    DUMPFILE=server-$NOW.tar.gz
    curl —user user@yandex.ru:password -T $DUMPFILE "https://webdav.yandex.ru/backup/"
    rm -rf /tmp/backuptmp/*
    
    • user@yandex.ru - Your e-mail address (login)
    • password - Your password

    Save it script as backup.sh in the directory /opt Create a directory backup in Yandex Disk

    Configure cron (Linux task scheduler)

    open the editor with the command

    sudo crontab -u root -e
    

    and in the opened file add a line:

    40 2 * * * sh /opt/backup.sh > /dev/null
    

    do not forget to put at the end of the line Enter (line break!)

    Save the file. Now at 2 hours 40 minutes (at night) You will have a backup of Astra in Your Yandex Disk in the backup directory with the current date.