Backing up your WordPress website is an important step. Often Bloggers and Webmasters forget to keep a backup of their hardwork. The importance of a backup is realised once the website gets compromised or when some important article is accidentally deleted. Therefore, in this article we’ll cover a raw method to backup your WordPress without FTP and cPanel. This method involves usage of SSH for backing up WordPress.
1. Contact your host for SSH login details
You might be using Hostgator, Godaddy or any other host. Contact your host by creating a ticket in the admin panel. Ask them to provide you SSH login details. They would give you a username and password. Write it down in some secure location as you are going to need it to backup WordPress without FTP.
After obtaining SSH login details, you have to use a SSH Client like Putty. In Linux or Mac you can use the default terminal for this process. Use the following command to connect to SSH.
ssh [email protected]
The syntax might be different depending upon the port number, incase your host uses a non-standard port. You can read SSH command in detail.
2. Start WordPress Backup without FTP or cPanel with Two Steps
There are two important things which you must know. As you are into your server with an SSH client. You have to backup these two things:
- WordPress Files (You can exclude core)
- WordPress Database (You need SQL database password)
2.1 Backup WordPress Files
You need to navigate to the folder in which your WordPress files are present on the server. It’s mostly under the public_html folder. In case you can’t find it, then make sure to search for folders with similar names using SSH command. Run the following command to make a compressed folder of the public_html folder containing WordPress files.
tar -czvf wordpress_files.tar.gz /path/to/public_html
Download wordpress_files.tar.gz to your local computer. You can use scp command to copy the file either into your computer or to another server which you own. The syntax of SCP command is as follows:
scp [email protected]:/wordpress_files.tar.gz [email protected]:/path-to-any-folder-where-backup-be-kept
Pro Tip: Move your backup file to public_html and visit browser with url www.yourwebsite.com/wordpress_files.tar.gz and start downloading. Don’t forget to delete the file or move it back to private folder.
2.3 Backup WordPress database
Since you have downloaded WordPress files. The next step is to backup WordPress database. Go to your downloaded files, find wp-config.php after extracting the wordpress_files.tar.gz. Open wp-config.php and look for the following lines:
// ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define( 'DB_NAME', 'database_name' ); /** MySQL database username */ define( 'DB_USER', 'username_db' ); /** MySQL database password */ define( 'DB_PASSWORD', 'password' ); /** MySQL hostname */ define( 'DB_HOST', 'localhost' );
You would need DB_USER and DB_PASSWORD value to login into SQL database. Open Putty or your favourite terminal. Connect to the ssh using the first step of this tutorial. Use the following commands to export WordPress SQL database
mysqldump -u username_db -p databbase_name > wordpress_database.sql
The above command would export the database without the use of cPanel or phpMyAdmin. Just like the first step; download the database file. You can use scp command to copy the files to some remote server.
Final Argument: Backup WordPress without FTP
It’s doable. The process is important for webmasters who don’t want to spend money buying cPanel license. Further, using ssh for server maintenance is a cool thing. It not only increases linux knowledge but at the same time allows more freedom. Downloading the backup files by putting them in public_html folder is a risky bet. Those who are conscious of security can use scp command. Cheers!
Let me know in comments, if you were able to do this tutorial.