How to create a backup of your files via SSH

Making a regular backup of your personal data is a very good practice to ensure your website is protected if something goes wrong. There are several ways to back up the data. One of them is to use Secure Shell (SSH).

First of all, make sure SSH access is enabled for your hosting account. The detailed description on how to connect via Secure Shell can be found here.

Once connected, you may start creating a backup of your files:

1. Navigate to the directory you would like to back up:


  • type cd directoryname to change a directory if you need to back up the files located in another folder (like public_html/nctest in our example):


2. Once you have chosen the directory you wish to back up, you are ready to start the backup process. Type the following command and press Enter:
tar -vcf mybackup.tar.gz . (do not forget about ‘.’ at the end):



You may replace mybackup with whatever name you want (and this will be the name of the newly generated backup). The backup will contain all the files and folders of the directory you were located in at the moment of the backup creation.

Once the process is completed, you will have a single .tar.gz archive with the necessary files inside. The backup file will be created in the same directory you have previously navigated to:



Feel free to log in via FTP and download it or do it directly in cPanel > File manager. In addition to files and folders stored on your website, you may also need to back up the database.


That's it!

              
                      Need any help? Contact our HelpDesk

Updated
Viewed
42461 times

Need help? We're always here for you.

notmyip