This script backup directories /etc/astra and file /usr/bin/astra to Google.Disk service.
wget -O /usr/bin/gdrive https://github.com/gdrive-org/gdrive/releases/download/2.1.0/gdrive-linux-x64 chmod +x /usr/bin/gdrive
gdrive list command. A link will be generated. Copy link and open it in your browser. This authorizes gdrive on Google services.
After authorization in the services, copy the authorization code and paste it into the console:
[root@server ~]# gdrive list Go to the following link in your browser: https://accounts.google.com/o/oauth2/auth?client_id=367116221053-7cpdoe99eg.apps.\ googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=\ code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&state=state Enter the code from the page: Enter verification code: 4/sgH7WCEJhlGTmWTOQ-Dvc6IbErAh2p0LbruYYFNnWSb2befbtafQltM Usage: drive [global options] <verb> [verb options]
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 /usr/bin/gdrive upload /tmp/backuptmp/$DUMPFILE rm -rf /tmp/backuptmp/*
Save this script as backup.sh in the directory /opt
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 Enter at the end of the line (to line break!)
Save the file. Now at 2 hours 40 minutes (at night) you will have a backup of Astra in your Google Disk in the backup directory with the current date.