Backup and Restore¶
How to backup EspoCRM manually¶
EspoCRM consists of files and database data. All these data are needed in order to create a full backup of EspoCRM. Here are the instructions on how to do it on Ubuntu server, with MySQL.
Step 1. Backup files¶
Create an archive of the directory content of installed EspoCRM. The default path for Ubuntu is
/var/www/html. You can use this command:
tar -czf "files.tar.gz" -C /var/www/html .
Step 2. Backup database¶
To backup all your data, you have to know the database name and access credentials. You can find the database name in the configuration file
/ESPOCRM_DIRECTORY/data/config.php under section
database. You can use this command to backup your database:
mysqldump --user=YOUR_USER --password=YOUR_PASSWORD YOUR_DATABASE_NAME > "db.sql"
Step 3. Copy the backup¶
That's all. Now, you have to copy the created backup to a safe place.
How to backup EspoCRM with a script¶
You can use a script to backup all needed data. Login via SSH and run the commands (tested on Ubuntu server).
Download a script¶
Run the script¶
bash ./backup.sh PATH_TO_ESPOCRM BACKUP_PATH
PATH_TO_ESPOCRMis a path to installed EspoCRM directory
BACKUP_PATHis a path to backup directory
For Ubuntu server it is:
bash ./backup.sh /var/www/html /opt/backups
Note: If your MySQL user doesn't have needed rights to dump your database, you will be prompted to enter credentials of another MySQL user.
After successful creation, you will get a path to the created backup.
Restore EspoCRM from a backup¶
You can restore EspoCRM from the backup created as described above.
Step 1. Unarchive backup files¶
To unarchive files, you can use Archive Manager or run the below command. Files need to be placed in the web-server directory.
tar -xzf "files.tar.gz" -C /var/www/html
/var/www/html is the web-server directory.
Step 2. Set required permissions¶
The files should be owned by a web-server user and have correct permissions. Please set required permissions by following this instruction.
Step 3. Import database dump¶
Database dump should be imported to the same database with the same user credentials, otherwise the correction should be made in the configuration file
ESPOCRM_DIRECTORY/data/config.php. To import your database from the dump, run the command below in a terminal:
mysql --user=YOUR_DATABASE_USER --password=YOUR_DATABASE_PASSWORD YOUR_DATABASE_NAME < db.sql
Step 4. Check/configure crontab¶
Check if your crontab is configured properly. Run the command below and check if a path to EspoCRM is correct:
sudo crontab -l -u www-data
www-data is your web-server user.
If you have to make any changes, use this command:
sudo crontab -l -u www-data
More details about configuring crontab for EspoCRM are described here.