How to back up Sitebuilder data?
Sitebuilder data can be backed up with the Backup feature in the Sitebuilder GUI, using the
sbbackup utility and dumping Sitebuilder data manually.
NOTE: The below methods allow to back up user and site configuration data on the Sitebuilder server. The site's data on the published server is not dumped.
Backup feature in Sitebuilder GUI.
Log in to Sitebuilder as the administrator and go to
Server > Backup.
Click Create Backup Now to start dumping.
After the dumping process is finished, you will see the dump you created:
NOTE: Dumping of Sitebuilder modules is a PHP memory-consuming process. Therefore, the following error might can be received, if there are many sites that use modules.
PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 2540273 bytes) in /usr/local/sitebuilder/include/SB/Site.php on line 818
In this case, a full backup of Sitebuilder is not created. As a solution, you may temporarily increase the
memory_limitparameter in Sitebuilder php.ini configuration file:
~# grep memory_limit /opt/php52/etc/php.ini memory_limit = 1024M ; Maximum amount of memory a script may consume (16MB)
Restart Apache and create the backup through the GUI. Then change the parameter back, and restart Apache.
IMPORTANT: Permanently increasing the memory_limit parameter in Sitebuilder PHP is not recommended, as server performance can be affected.
After creating the backup, change the
memory_limitparameter back to the recommended value of 64M.
Alternatively, you may back up all Sitebuilder objects (users, sites) one-by-one with the
Sitebuilder backup with the
sbbackuputility. To back up all content:
# /usr/local/sitebuilder/utils/sbbackup all --compress --output=/BACKUP/DIR/ALL_BACKUP.gz
/BACKUP/DIRis the directory where backup files are saved to. Select a valid location of your choice.)
Again, note that dumping of Sitebuilder modules is a PHP memory-consuming process. If there are many sites that use modules, you might get an empty resulting file, ALL_BACKUP.gz.
Use the command below to dump the user
and all its sites.
# /usr/local/sitebuilder/utils/sbbackup user --uuid=<user uuid> --with-sites --with-site-content --recursive --compress --output=/BACKUP/DIR/USER.NAME_BACKUP.gz
If the user is a Reseller, then all Site Owners that belong to the user are dumped with this command.
The following MySQL query can be used to get a list of UUIDs for regular Sitebuilder users:
mysql> select uuid from user where user_name not like 'admin%';
Manual dumping of Sitebuilder data.
To back up Sitebuilder data, you may simply save the
/usr/local/sitebuilder/configfile, and the sitebuilder3 database. You may use the following commands to back up the site directory and configuration:
# tar -zcf sitebuilder.dump.`date +%F.%s`.tgz /usr/local/sitebuilder/htdocs/sites /usr/local/sitebuilder/config ~# mysqldump -u<user> -p<password> sitebuilder3 > /BACKUP/DIR/sitebuilder3.dump.`date +%F.%s`.sql
<user>/<password>are the username and password for the MySQL administrator.)
The exact name of the Sitebuilder database can be found using the sb_config utility:
# sb_config --help | grep sb_db_name --sb_db_name Sitebuilder database name [sitebuilder3]
Scheduled backup of Sitebuilder.
To create a scheduled backup task, create a script that dumps all content of Sitebuilder, and put the script into crontab.
Below are examples of such a script.
This first script is for dumping all content. As a result, one backup file is created in the
sbbackup.sh --- #!/bin/sh sbbackup="/usr/local/sitebuilder/utils/sbbackup" sbbackup all --compress --output=/BACKUP/DIR/ALL_BACKUP.gz ---
The following script is to dump all Sitebuilder users with their sites. As a result, a backup file for each Sitebuilder user is created in the
sbbackup.sh --- #!/bin/sh mysql_bin="/usr/bin/mysql" # mysql binary mysql_user="admin" # user of mysql administrator passwd="setup" # password for mysql administrator mysql_opt="-NB" mysqlsb="$mysql_bin $mysql_opt -u$mysql_user -p$passwd sitebuilder3" sbbackup="/usr/local/sitebuilder/utils/sbbackup" query="select uuid from user where user_name not like 'admin%'" for user in `echo "$query" | $mysqlsb` do $sbbackup user --recursive --compress --with-sites --with-site-content --uuid=$user --output=/BACKUP /DIR/$user.dump.`date +%F.%s`.gz done ---