Frankly the prestashop documentation on this is pretty good. This whole process is much like backing up any other server with ubuntu where you need to back up two things:
- your site files
- your database
If you followed my how to install prestashop on ubuntu server blog then this is a similar setup. If this isn’t your setup, consider a different tutorial.
If you are reading this and thinking “ok, great, I’ve done a file and mysql backup. I know what to do. See you later”, just note one thing: There is a weird change with the July 2020 Mysql which seems to create some request for some ‘PROCESS’ powers on the mysql user. If you hit that snag, this blog deals with it and the
--no-tablespaces option makes it work again.
Back up the Database
Basically, you can follow my suitecrm blog here and just follow the section called ‘Backing up your SuiteCRM MYSQL Database’. Just note the new weird tablespaces thing above…
My new command looks like this (I run it after navigating to the place I want the file to be):
sudo mysqldump --no-tablespaces -u prestashopuser -p prestashop_db > prestashop_backup_yymmdd.sql
You will be prompted for the password and interestingly I always get snagged on the password step thinking it needs some admin user password in Mysql when in fact it just needs the password for the user you entered in the command….
All good? Is the .sql file where it should be now? Continue forward!
Backup the Prestashop Site Files
The prestashop documentation got me most of the way there, especially I appreciated the compression command which I didn’t take advantage of before. However, the documentation didn’t say I had to use
sudo privileges. So, I just used the
cd command to move to the directory I created for the backups, then this is what my command looks like which zips up and dumps all the prestashop site files to a tar file:
sudo tar -czf presta_files.tar /var/www/prestashop/
The resultant file in the directory after it completed was
presta_files.tar as expected.
Download the Files to Local Machine for Safe Keeping
You can use the handy
sftp command in your terminal as outlined in my SuiteCRM backup blog above, or, you can use the even more simple Nautilus ‘other locations’ method to just use a visual GUI-based way of moving files. It’s like FTP kind of way but even easier where you just drag the stuff from your server to your machine. Here is how you do it:
- Open Nautilus (File Manger)
- Go to the ‘+ Other Locations’ option in your left pane
- Enter your ssh info into the field like this, but just before pressing ‘enter’ on your keyboard, make sure to copy your password to your clipboard memory:
‘root’ is your ssh username for your server
‘126.96.36.199’ would be your IP address of your server
Press enter and enter your password.
Go to your MySQL dumped files and your presta_files.tar file and drag them to your local machine.
Optional but wise step: unzip your presta_files.tar file to make sure the stuff is all in there 🙂
TIP: disconnect right after you’re done your work. It’s easy to goof up while you are logged in through your File Manager and it’s easy to mess up your server.