Views: 1926 (Data available since 06.02.2017)
Often, when deploying project, based on BitrixVA/BitrixEnv, a backup copy for the project is required.
Automatic backup feature for the site and the database is available in BitrixVA/BitrixEnv. Backup will be created as per schedule in the .tar.gz archive format and recorded in the directory
This method has both advantages and disadvantages, compared to Bitrix24 products built-in backup copy mechanism:
- Advantages: higher creation speed for backup copy and independence from project performance.
- Disadvantages: backup copy cannot be created for files, stored in Cloud-storage drives.
To create scheduled automatic backup copy via BitrixVA/BitrixEnv tools:
- Select item 6. Manage sites in the pool > 6. Change backup settings on site in the Virtual Appliance settings.
- Select host name from the list and confirm the option to change of automatic backup schedule:
- Select period and hour for the start of automatic backup:
If more detailed configuration for backup is required, command line utility can be used:
/opt/webdir/bin/bx-sites -a backup -d dbcp --enable --minute=10 --hour=18 --day=any --month=any --weekday=any
: How to configure the correct time in BitrixVA/BitrixEnv
- After this step, the work of configuration wizard is finished. The task to create backup copy for project is added in Cron (
Backup is created for kernel (site type kernel and ext_kernel) and its all links, if such exist.
To perform backup, the task is created in crontab-file. For example:
10 22 * * * bitrix /opt/webdir/bin/bx_backup.sh sitemanager0 /home/bitrix/backup/archive
As the first option, DB name is added; second option indicates catalogue, where the archive will be created.
As a result, the following type of archive will be created by the script: www_backup__DD.MM.YYYY_<random_string>.tar.gz (for example - www_backup_dbcp_21.10.2014_1RJKXbMv.tar.gz).
The following files could exist inside the archive:
- DB dump
- site kernel data
- sites Links-type data with full path
Backup management via bx-sites
-a|--action - action to manage the site; in this case it executes backup
-d|--database - DB name (data for all sites that use this DB will be contained in the backup)
--enable|--disable - enabling and disabling backup for sites
--minute - parameters for crontab file record (minutes)
--hour - parameters for crontab file record (hours)
--day - parameters for crontab file record (day)
--month - parameters for crontab file record (month)
--weekday - parameters for crontab file record (week day)
In case of successful execution, the utility will return new options for site:
/opt/webdir/bin/bx-sites -a backup -d sitemanager0 --enable --minute=10 --hour=23 --day=1 --month=any --weekday=any -o json | python -mjson.tool
Several files/catalogues are queried to be excluded from the backup copy. The list of such exclusions can be found in the file /opt/webdir/bin/ex.txt.
By default, it contains the following subcatalogues:
As noted above, backup includes:
- site kernel catalogue itself (kernel или ext_kernel);
- DB dump file (
- sites catalogues (link), which use the kernel.
For example, the command:
/opt/webdir/bin/bx_backup.sh sitemanager0 /home/bitrix/backup/archive
creates file www_backup_sitemanager0_30.01.2015_bnnW1NPm.tar.gz in the directory
To perform backup, it is necessary to go to DocumentRoot of the kernel. Execute:
tar xzvvf www_backup_sitemanager0_30.01.2015_zEQkXREd.tar.gz ./
-rw-r--r-- bitrix/bitrix 5013 2015-01-30 14:02 ./workgroups/.left.menu_ext.php
-rw-r--r-- bitrix/bitrix 319 2015-01-30 14:01 ./.top_links.menu.php
-rw-r--r-- root/root 5313008 2015-01-30 14:22 home/bitrix/mysql_dump_sitemanager0_30.01.2015_bnnW1NPm.sql
drwxr-xr-x Creating directory: home
drwxr-xr-x Creating directory: home/bitrix
-rw-r--r-- root/root 44 2015-01-30 14:22 home/bitrix/mysql_dump_sitemanager0_30.01.2015_bnnW1NPm_after_connect.sql
After that, DB is to be restored:
mysql sitemanager0 < home/bitrix/mysql_dump_sitemanager0_30.01.2015_bnnW1NPm_after_connect.sql
As well as the data of additional sites, if available:
rsync -av home/bitrix/ext_www/ /home/bitrix/ext_www/
Attention!: Do not forget to monitor the space on disk and periodically delete old backup copies.