Contents
The following article describes and explains how you can set up an automatic backup via FTP in your xentral.
Note: This feature is only for on-premise customers. For customers with cloud instances, backups are automatically created by xentral.
The following areas should be backed up regularly:
- Folder userdata
- Dump of the MySQL database
xentral recommends to transfer the folder userdata and the last MySQL backup every night via FTP to an external server. During the day xentral recommends to backup the database e.g. at 07.00 / 12.00 / 15.00 and 18.00. This way a loss would be maximum 1/3 working day. In case of high volume, the frequency can be adjusted accordingly.
The backup is done via cronjob. Optionally, a snapshot or backup could also be created or downloaded manually via Administration → System → Backup using a browser.
Note: In the storage location, the parent directory must also be entered.
Set up automatic FTP backup in xentral
To set up an automatic FTP backup in xentral, the following access data and rights are required:
- Access data to the FTP server
- Access data to the MySQL database
- read and write access to the HTTP directory of the xentral server
- Administrator rights (root) for the xentral server to set up the cronjob for the FTP backup
The FTP Backup App
In the first step, the access data to the FTP server must be stored in xentral. To do this, log in to xentral and then navigate to App Center > FTP Backup.
The access data for the FTP server must be entered here. This app is only used to check whether the backups are stored regularly.
The access data to the FTP server must be entered in the fields.
FTP Backup Setup
In order for the backup to start automatically, the access data for the SQL database and FTP server must be entered in the FTP backup script.
To do this, call the console (terminal) under Linux and log in as root.
Note: To log in as root, enter "sudo su" in the console and confirm the command with ENTER. After that, the system will ask for a password, which must be entered and confirmed with ENTER. Note that the letters are not displayed when entering the password.
Now change to the directory where the FTP backup script files are located. Usually the files are located under /var/www/http/backup/.
To change to the directory, enter the following command in the console:
cd /var/www/html/backup/
If ls is now entered into the console, two folders and two files are displayed.
Only the files mysql_ftp.php.tpl and userdata_ftp.php.tpl are important, these contain the FTP backup script for the database mysql_ftp.php.tpl and for the userdata directory userdata_ftp.php.tpl.
The first thing to do is to rename the two files. To do this, enter the following commands in the console mv mysql_ftp.php.tpl mysql_ftp.php ENTER and then mv userdata_ftp.php.tpl userdata_ftp.php ENTER.
After the files have been renamed, they must now be edited and the access data to the SQL database and the FTP server must be stored.
To do this, enter the following command in the console:
nano mysql_ftp.php
and confirm it with ENTER.
Now these lines have to be adapted for SQL access:
$WFdbname='';
$WFdbuser='';
$WFdbpass='';
in e.g.:
$WFdbname='wawision';
$WFdbuser='root';
$WFdbpass='12345';
And the lines for FTP access:
$ftp_server="";
$ftp_user_name="";
$ftp_user_pass="";
in e.g.:
$ftp_server="192.168.0.201“;
$ftp_user_name="ftpbackup";
$ftp_user_pass="12345";
To save the changes, press "CTRL+O" on the keyboard and confirm the saving with ENTER. Then press the "CTRL+X" keys to exit the editor.
Now edit the second file with the command "nano userdata_ftp.php" and confirm with ENTER.
And the lines for FTP access:
$ftp_server="";
$ftp_user_name="";
$ftp_user_pass="";
in e.g.:
$ftp_server="192.168.0.201“;
$ftp_user_name="ftpbackup";
$ftp_user_pass="12345";
To save the changes, press "CTRL+O" on the keyboard and confirm the saving with ENTER. Then press the "CTRL+X" keys to exit the editor.
Note: If the installation of xentral is stored in a different directory than specified in userdata_ftp.php, the line must be adjusted accordingly:
$userdata = "/var/www/html/userdata";
Tip. With the command php mysql_ftp.php followed by ENTER you can start the script and check on the FTP server via FTP client if the backup is stored. This can also be tried with the userdata_ftp.php.
Set up cronjob for FTP backup
In order for the backup to start automatically now, two new commands must be added to the cronjob on the server. To edit the cronjob file, enter the following command in the console:
sudo crontab -e -u www-data
and confirm with ENTER.
At the end of the data, add the following lines:
0 0 * * * php /var/www/html/backup/mysql_ftp.php
0 1 * * * php /var/www/html/backup/userdata_ftp.php
The first line starts the SQL backup every day at 0:00 and the second line starts the userdata backup every day at 1:00. The entries should look something like this:
In order to save the changes, it is then necessary to press "CTRL+O" on the keyboard and press ENTER to save. Afterwards the keys "CTRL+X" have to be pressed to leave the editor.
Note: If the installation of xentral is stored in a different directory than specified in the example, the lines must be adapted accordingly:
0 0 * * * php /var/www/html/backup/mysql_ftp.php
0 1 * * * php /var/www/html/backup/userdata_ftp.php
Importing backups
Dumps should be imported with the command line tool mysql: https://dev.mysql.com/doc/refman/5.7/en/mysql-batch-commands.html