The administrator of an X-Cart-based store can back up the database in a few easy steps directly from the Admin area.
If your X-Cart store uses any 3rd party or custom add-ons, and the data of these addons locate not in the X-Cart database but elsewhere, these data will not include in the database backup created with the X-Cart’s standard backup utilities.
Hence there can be cases when you have to back up the database manually, so the dump includes all the store data. For this purpose, you can use any adequate facility, including different client implementations of the SSH protocol like OpenSSH or PuTTY, Telnet, phpMyAdmin, MySQL console, a control panel of your hosting account, Remote Desktop client, and others.
Database Backup Using X-Cart Admin Area
To back up the database through the X-Cart Admin area:
First, open the “Backup database” page in your store Admin area (System tools -> Database).
Make sure the customer storefront is closed as described here.
Create a database backup using one of the following ways:
Download SQL file: An SQL file will be downloaded to your local computer.
Create SQL file: An SQL file will be saved on the server your store is hosted at. You will be able to download the file from the server later and, after that, delete it from the server using the “Delete SQL file” button.
If you do not have access to your server/hosting account through FTP, SSH, or other suitable facilities, use the “Download SQL file” variant and save the SQL file directly to your local computer.
Database Backup Using Terminal Access
To back up the database using terminal access to the server:
First, log in to your server or hosting account.
Go to the X-Cart root directory.
Run the following shell command.
mysqldump -h<db_host> -u<username> -p<password> -r<backup_filename> <db_name>
The abbreviations in the command mean:
The DNS name or the IP address of your MySQL server.
The username for your MySQL user account.
The password for your MySQL user account.
The name and the path to the newly created SQL file with the database dump.
The name of the MySQL database that you use for X-Cart.
After you have run the command, the system will generate an SQL file and save it to the directory that you have specified in the part of the command. For example, if you have specified the file's name for the backup only without mentioning the path, the file will be saved to the X-Cart root directory, the directory where you are currently located.
If necessary, you can use a different path, but it is recommended that it be a location within the X-Cart root directory.
Backup of the Store Files
Creating a backup copy of the store files presumes that you pack all the files in the X-Cart root directory into an archive and then copy or move the archive to a new location on the remote server or your local computer.
If you have previously saved the database dump into the file in the X-Cart root directory, the file will also be included in the archive.
To create an archive, you need to use a file archive manager. The exact choice of the archive manager will depend on the operating system you use. On a UNIX-based server, the most popular archive manager, which is currently installed on most servers, is TAR.
Below, you will find an example of archiving the X-Cart files with the TAR archive manager.
On a Windows-based server, you can create the archive with one of the available file archive managers for Windows, including WinRAR, WinZIP, PKZip, and 7Zip. First, you need to pack the whole X-Cart root directory to an archive and then save the archive to the parent of the X-Cart root directory.
Alternatively, if it is not possible to pack the X-Cart files into an archive directly on your server, you can copy the X-Cart root directory to your local computer or another remote server using FTP or other suitable facilities. Before that, make sure the new location you plan to copy the X-Cart root directory has enough free disk space. Besides, the control panel of your hosting provider may offer its own facilities for backing up your account data.
Files Backup Using TAR Archive Manager (UNIX-based servers only)
In UNIX-based systems, TAR is one of the most reliable and trustworthy utilities for creating and manipulating file archives. It is now commonly used in tandem with external compression utilities like GZIP, BZIP2, or LZMA, which enables you to create an archive and compress the data in the archive. As a result, with TAR, you can create a lightweight archive of your store and restore it using the same utility. To find out whether TAR is installed on your server, run the following shell command.
If TAR is installed on your server, the system will display a message with the utility version; otherwise, you will see an error message. In case of the latter, please contact your hosting team for help.
To back up files with the TAR archive manager:
First, log in to your server or your hosting account.
Go to the X-Cart root directory.
In the X-Cart root directory, run the following shell command.
tar -czvf ../store_backup.tgz *
After running the command, TAR will pack all the files in the X-Cart root directory to the file store_backup.tgz and compress it with the ZIP data compression algorithm. Then, the file will be saved to the directory that is parent to the X-Cart root directory. For example, if the X-Cart root directory is u/user/public_html/xcart, the file store_backup.tgz will be saved to directory u/user/public_html.