lcp

How to create a full backup of your Una website?

How to create a full backup of your Una website?

It is always as good practice to generate a backup of your website before making changes over the course of designing or upgrading your website. This will allow you to restore your website if any errors occur and allow you to start over. Despite the fact that we are generating regular backups through our Shared server you can backup your website whenever you need to. In this article, we will introduce you to some of the most common practices to generate a backup.

  1. Generating backup via cPanel

The first step is to create an archive of the files of the website. For this navigate to cPanel > File Manager under the “Files” tab as shown below:

After accessing the File Manager tool select the root folder of your UNA website and use the “Compress” toll present in the top menu bar:

You will be given several options from which you choose the type of archive that will be created. The most common type is the ZIP Archive:

After choosing the type of archive and the name the file will be saved in the “/home” directory of your account which you can now download directly from the “File Manager”.

After creating a backup of the files we can proceed with exporting a backup of the database that the UNA application is using. To check which is the exact database that the application is using you will have to navigate to “/home/una-root/inc/” and view the “header.inc.php” file. In this file, you will find information about the Database Name, Database User, and Database password.  

Below you can see the section in which the credentials of the database are defined:

Now you will have to navigate to cPanel > PHPMyAdmin in the “Database” section:

After accessing the “PHP My Admin” control panel you will have to choose the database of the website and then use the “Export” option in the toolbar as shown below:

Now to proceed click on the “Go” option as this will export the database “.sql” file format. You can download the file to a location on your device.

  1. Creating backup via FTP connection

        Another way to back up the files of your UNA application is to use FTP connections to directly download the files of the website to your device. In this example, we will be using the “FileZilla” FTP software, however, you can use a software of your choice.

        To begin you will have to access the file system of your account by entering the FTP credentials which were provided upon sign up in the “Welcome Email”. Entering the file system should look similar to this:

 

        In order to download the root directory of the website – e.g. “public_html” move the mouse cursor over the folder, right-click and choose option “Download”. The database you again can download using the “PHP My Admin” tool described earlier.

  1. Generating backup via SSH shell connection

 

        If you are more comfortable using the terminal there is also an easy way to backup your website using the commands that will be presented in this section.

        Start by establishing an SSH connection to your account so you can enter the file system. To connect through SSH connection you can use applications similar to PyTTY (used in Windows OS)  or connect via the terminal if you are running Unix or macOS.

        We will begin by creating a backup of the database that the website is using. First, you will have to enter in the root directory where UNA is installed and check the what is root database that the website is using as we will need the name, user, and password of that database.

        

Now there are several of ways to check the credentials, but we will show you the easiest using command “cat” in combination with “grep”. The full command you can see below:

cat inc/header.inc.php | grep "DATABASE"

        The output of the command will display the user, password and the name of the database – information we will need to export the database.

        Knowing the database credentials we can proceed with creating a database backup using the following command:

mysqldump -p [DB NAME] -u [DB USER] > backup-name.sql

        For the purpose of this tutorial, we will use the credentials shown above so the final output of the command will look like this:

mysqldump -p tmdtuto1_una622 -u tmdtuto1_una622 > backup-tmdtuto1_una622.sql

        After entering the command you will be asked for a password to proceed. Entering the password of the database will complete the creation of the backup. The file will be using the name you have set and will be saved in the root directory of your account.

        The next step is to generate a backup of the root directory of the UNA installation where a backup of the database will be present. To proceed enter the “/home” directory of your account using the command “cd”. Then you will have to use the following command to generate an archive file of the root directory:

 tar -zcf backup-name.tar.gz path-to-directory/

        In the terminal, the command will look like this:

        This will generate a “.tar.gz” file in containing the files and database of your website in the home directory of your account. The file will use the name you have set earlier.