Backup
Rus
Eng
Резервное копирование

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

Original solution here

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

There are no comments yet, you can be the first to leave it

Leave a comment

The site uses a comment pre-moderation system, so your message will be published only after approval by the moderator

You are replying to a user's comment

Send

FEEDBACK

Email me

Are you developing a new service, making improvements to the existing one and want to be better than your competitors? You have come to the right place. I offer you a comprehensive studio-level website development. From me you can order design, layout, programming, development of non-traditional functionality, implementation of communication between CMS, CRM and Data Analitics, as well as everything else related to sites, except for promotion.

Contact, I will always advise on all questions and help you find the most effective solution for your business. I am engaged in the creation of sites in Novosibirsk and in other regions of Russia, I also work with the CIS countries. You will be satisfied with our cooperation

An error occurred while sending, please try again after a while
Message sent successfully

Phones

+7(993) 007-18-96

Email

info@tichiy.ru

Address

Россия, г. Москва

By submitting the form, you automatically confirm that you have read and accept the Privacy Policy site

Contact with me
Send message
By submitting the form, you automatically confirm that you have read and accept Privacy policy of site
Sending successful!
Thank you for contacting :) I will contact you as soon as possible
Sending failed
An error occurred while sending the request. Please wait and try again after a while or call my phone number