Backup WordPress website procedure for Linux

To backup your WordPress website on Linux you can follow these steps:

1. Log in via ssh to your server.

2. Change directory where your website files are located. For example:
$ cd /home/shkodenko/public_html

3. Find out MySQL connection settings using command:
$ grep -ni "DB" ./wp-config.php

You will need these lines below.
19:define(‘DB_NAME’, ‘db_name’);
22:define(‘DB_USER’, ‘db_user’);
25:define(‘DB_PASSWORD’, ‘db_password’);
28:define(‘DB_HOST’, ‘localhost’);

4. Create backup of MySQL database using mysqldump utility. For example:
$ mysqldump -h localhost -u db_user -p db_name > ./wp-content/uploads/db_name.sql

5. I am checking MySQL dump using tail and head utilities:
$ tail -n 15 -f ./wp-content/uploads/db_name.sql
$ head -n 15 -f ./wp-content/uploads/db_name.sql
I am using sha1sum command to get SQL dump file checksum:

$ sha1sum -b ./wp-content/uploads/db_name.sql
I am checking SQL dump file information usinng ls command:

$ ls -Alh ./wp-content/uploads/db_name.sql
All these steps above in 5 can be skipped. I making these checks for history and possible future verification purposes if something will go wrong.

6. Making archive:
tar cpjf /home/shkodenko/shkodenko.com-backup.tar.bz2 ./

7. Some additional commands for verification with backup file:
$ sha1sum -b /home/shkodenko/shkodenko.com-backup.tar.bz2
$ ls -Alh /home/shkodenko/shkodenko.com-backup.tar.bz2

8. Cleaning garbage:
$ rm -fv ./wp-content/uploads/db_name.sql

2 thoughts on “Backup WordPress website procedure for Linux

  1. Thank you for sharing excellent information. Your website is so cool. I am impressed by the details that you’ve on this website. It reveals how nicely you understand this subject. Bookmarked this website page, will come back for more articles. You, my friend, ROCK! I found just the info I already searched all over the place and just could not come across. What an ideal website.

Comments are closed.