The last notes
All English-language materials have been translated fully automatically using the Google service
Regular automatic site backup based on bash
script
The script performs regular automatic creation of a database dump at the root of the site, archiving all files and then deleting the dump from the root
#!/bin/bash
# Number of days to keep copies
days=28
# Path to the folder with files for storing copy files
backup_dir="backups"
# Site directory name
site_dir="PATH_TO_YOUR_SITE/public_html"
# Database name
db_name="YOUR_DB_NAME"
# Password to access the database
db_pass="YOUR_DB_PASSWORD"
d=`date +%F-%H:%M:%S`
mkdir -p $backup_dir 2>/dev/null
# Deleting old copy files
find $backup_dir -name "*autobackup.tar.gz" -type f -mtime +$days -delete
# Database dump
dump_name="$site_dir/dump-$d.sql"
mysqldump -h localhost -u$db_name $db_name -p"$db_pass" > $dump_name
# Archiving files
tar cvvzf "$backup_dir/YOUR_SITE_NAME-$d-autobackup.tar.gz" $site_dir --exclude=bitrix/cache --exclude=bitrix/backup
# Remove the dump from the site root
rm $dump_name
This archive can be automatically saved to Yandex disk. You can implement this by adding the command to the end of the script:
curl -T "$backup_dir/YOUR_SITE_NAME-$d-autobackup.tar.gz" -u"YANDEX_USER_LOGIN:YANDEX_USER_PASSWORD" https://webdav.yandex.ru/
Save the script in any folder on your account with the extension .sh
and give the file execution permissions with the following command:
chmod u+x backup.sh
Add this file to the crowns with a command like this
*/1 * */14 * * /bin/bash ~/fullBackup.sh
The solution is provided "as is". Use it at your own risk
Automatic site backup to Yandex.Disk
For automatic copying, install an unofficial client from Anton Batenev
git clone https://github.com/abbat/ydcmd.git
sudo cp ydcmd/ydcmd.py /usr/local/bin/ydcmd
yum install python-dateutil
Getting a token for working through the API
ydcmd token
A link will be sent as a response, by clicking on which you will receive a confirmation code. To get a token, copy the received code and run like this:
ydcmd token КОД_ПОДТВЕРЖДЕНИЯ
Create a .ydcmd.cfg
file in the user folder with 0400
rights and content
[ydcmd]
token = РАНЕЕ-ПОЛУЧЕННЫЙ-OAuth token-
verbose = yes
It remains only to add the cron command
10 1 * * * root /usr/local/bin/ydcmd put --rsync /home/bitrix/www/bitrix/backup disk:/YANDEX_DISK_ACCOUNT_EMAIL
Manual unpacking of a multi-volume Bitrix backup
If the Bitrix archive was compressed without using encryption, then it can be unpacked. To do this, you will need to change the extensions of all parts of the archive
.tar.gz to .tar.gz.001 for the first file
.tar.gz.1 to .tar.gz.002
.tar.gz.2 to .tar.gz.003 etc. for everyone else
You can then unpack it like a normal multi-volume archive.
Comments