Been a big fan and user of SuiteCRM for years. Never really did learn how to properly back up from my own server so yeah. Time to do it!
Backing up your SuiteCRM MYSQL Database
This is not for saving the files (ie. the custom settings you have made to SuiteCRM over the years and all the PDF templates, workflows, etc). This is just a raw datadump of the database. Be sure also to back up the suitecrm app files as a separate step (to be documented)
- ssh into the server with the usual
- cd to a location where you would like to back things up. I’ll just do the home directory for mine:
- Create a directory into which your backup will go. I will do example in home directory with directory name ‘suitecrm_backups’:
- CD into this new directory:
- Perform this command inserting the appropriate data:
mysqldump -u admin_user -p suitecrm_DB_name > suitecrm_backup_yymmdd.sql
If you happen to forget the name of your database, you can log into mysql with your user/pw and use this command to show all databases. Login
mysql -u admin_user -p and then show the databases with
- After the quality dump, look inside directory to make sure it’s all there and looking good:
ls -al | grep suitecrm_backups
- Great! Now you’ll have to go and get that file off your server and you can skip to the ‘Retrieving Your Backed-up Files’ section below to do that now if you’d like.
Special thanks to this blog
Backing up your SuiteCRM Files
Now that you have your mysql database is backed up, create a file on your server where the soon-to-be backed-up SuiteCRM-specific files will go. It must be writable by the SuiteCRM user so I put mine right in the SuiteCRM folder in var/www/html/suitecrm’, although not sure if that’s a good idea. I’m just not smart enough to know but it did work. I’m pretty sure this folder would not make it through an upgrade, though, so we’d have to back up just before the upgrade and then re-create it after, I’m guesssing.
- Navigate to a good place:
cd / var/www/html/suitecrm
- Make the backup directory:
- Give directory correct permissions:
sudo chown -R www-data:www-data /var/www/html/suitecrm/suite_backups
sudo chmod -R 755 /var/www/html/suitecrm/suite_backups
- In the Suitecrm user interface, go to ‘Admin / Backups’
- Enter the path to the directory you just made in step 2 in the ‘directory’ field. Mine looks like this with the ‘var’:
- Enter the name of the file you want to call the zip file (ie. suitecrm_backup_yymmdd.zip) NOTE it seems that the system does not append the .zip so you have to make sure to manually enter it in this field.
- Confirm your settings. If it’s good you will be able to press ‘Run Backups’ button otherwise you’ll be told what is wrong.
- Press “Run Backups”
- If everything worked well it will tell you it was done correctly and sitting in the folder.
- Check to make sure it’s there with
- All good? Go ahead and download it using the cool sftp tool in the “Retrieving Your Backed-up Files” section below.
Retrieving Your Backed-up Files
- Open new terminal window on your local machine if you are like me and already logged into your suite machine in the original window above.
- In your new terminal window, navigate to where you want the backup files to end up. If you do nothing, they will end up in your HOme directory, but this is the one slightly weird thing to me. You can’t really change this later so do it now for simplicity, or at least note all your stuff will end up in your home directory.
- Log into the server in nearly identical way as ssh:
sftp firstname.lastname@example.org enter password when prompted
- Navigate to your file using your familiar
lscommands. So easy. In fact, just like ubuntu terminal navigation…
- When you track down your desired file, do a
get filename.zipand wait. You should see some ‘fetching’ comments and then it will end. Check to make sure you have it.
Hope this all helps. Thanks to the team at SuiteCRM.