{"id":4823,"date":"2020-04-08T17:51:44","date_gmt":"2020-04-08T17:51:44","guid":{"rendered":"https:\/\/lamp.ciscoar.com\/?page_id=4823"},"modified":"2020-11-06T23:00:47","modified_gmt":"2020-11-06T23:00:47","slug":"how-to-backup-a-wordpress-website","status":"publish","type":"page","link":"https:\/\/lamp.ciscoar.com\/?page_id=4823","title":{"rendered":"How to backup a WordPress website"},"content":{"rendered":"\n\n\n<h2 class=\"wp-block-heading\">Manual backup vs plugin<\/h2>\n\n\n\n<p>As you can imagine there are a lot of useful plugins to help you on the task of making a backup of your WordPress website, as always we do have pros and cons when using plugins, in my case and for this particular task I prefer to make backups manually, so, if you are someone like me who likes to have full control and also have proper knowledge of Linux, then feel free to go over this article to learn how to do a manual backup.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Backup and restore<\/h2>\n\n\n\n<p>Most of you will be happy just having the backup saved into your preferred storage device, but some of you may also want to restore the backup on a local LAB, and that&#8217;s in my opinion the best aproach because then you have a local copy of your website running as the best way to verify that your backup is good.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Restore to Windows vs restore to Linux<\/h2>\n\n\n\n<p>If you plan to restore the backup on a Windows machine, let&#8217;s say you are running WAMP then you don&#8217;t have to worry for the ownership nor for the files and folders permissions, but if you plan to restore the backup on a local Linux Virtual Machine then be sure you use <strong>tar <\/strong>and <strong>gzip<\/strong>, to keep both ownsership and permissions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Manual backup<\/h2>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>WordPress Manual backup is quite easy, basically you compress the wp-content folder along with the database (.sql) file, and that&#8217;s it!.<\/p><cite>WordPress manual backup<\/cite><\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">Which tools are needed?<\/h2>\n\n\n\n<p>To be able to perform a manual back first of all you need an account with &#8220;sudo&#8221; privileges, also access to <strong><a rel=\"noreferrer noopener\" href=\"\/phpmyadmin\/\" target=\"_blank\">phpMyAdmin <\/a><\/strong>with proper rights, and finally an FTP tool to download the compressed file to your local machine, we are going to use <strong><a rel=\"noreferrer noopener\" href=\"\/winscp\/\" target=\"_blank\">WinSCP <\/a><\/strong>for that.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1 &#8211; Use phpMyAdmin for database backup<\/h2>\n\n\n\n<p>The follow animation shows you how to do a <strong><a href=\"\/mysql\/\" target=\"_blank\" rel=\"noreferrer noopener\">MariaDB <\/a><\/strong>(mysql database) backup using the GUI provided by <strong>phpMyAdmin<\/strong>.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"916\" height=\"512\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-database-backup-phpmyadmin.gif\" alt=\"\" class=\"wp-image-4840\"\/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2 &#8211; Compress &#8220;wp-content&#8221; folder<\/h2>\n\n\n\n<p>This backup will be restored on a local <a rel=\"noreferrer noopener\" href=\"\/installing-centos-7\/\" target=\"_blank\">Linux Centos 7<\/a> virtual machine where <a rel=\"noreferrer noopener\" href=\"\/installing-wordpress\/\" target=\"_blank\">WordPress <\/a>has been installed, and where the <a rel=\"noreferrer noopener\" href=\"\/theme-twenty-seventeen\/\" target=\"_blank\">Theme Twenty Seventeen<\/a> was activated, nothing else has been done, so, the website is empty, that&#8217;s the reason why we&#8217;re going to use <strong>tar <\/strong>&amp; <strong>gzip <\/strong>to create a compressed file which preserves the ownership and permissions settings.<\/p>\n\n\n\n<p>Once you are located in the root folder of your website, you can run &#8220;tar&#8221; as shown below.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"vim\" class=\"language-vim\">tar -cf bkp-wp-content-folder.tar .\/wp-content<\/code><\/pre>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-backup_1.tar_file.png\"><img loading=\"lazy\" decoding=\"async\" width=\"931\" height=\"226\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-backup_1.tar_file.png\" alt=\"\" class=\"wp-image-4849\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-backup_1.tar_file.png 931w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-backup_1.tar_file-300x73.png 300w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-backup_1.tar_file-768x186.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/a><\/figure><\/div>\n\n\n\n<p>Use the CLI command below to see the size of the &#8220;.tar&#8221; file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"vim\" class=\"language-vim\">ls -lha bkp-wp-content-folder.tar<\/code><\/pre>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-backup_2.tar_file_size.png\"><img loading=\"lazy\" decoding=\"async\" width=\"650\" height=\"149\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-backup_2.tar_file_size.png\" alt=\"\" class=\"wp-image-4855\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-backup_2.tar_file_size.png 650w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-backup_2.tar_file_size-300x69.png 300w\" sizes=\"auto, (max-width: 650px) 100vw, 650px\" \/><\/a><\/figure><\/div>\n\n\n\n<p>As you can see the size of the &#8220;.tar&#8221; file is <strong>119 Mb<\/strong><\/p>\n\n\n\n<p>Once the &#8220;.tar&#8221; file is created you can compress it using for example &#8220;gzip&#8221; that comes with CentOS 7 by default.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"vim\" class=\"language-vim\">gzip bkp-wp-content-folder.tar<\/code><\/pre>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-backup_3.gz_file.png\"><img loading=\"lazy\" decoding=\"async\" width=\"617\" height=\"148\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-backup_3.gz_file.png\" alt=\"\" class=\"wp-image-4857\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-backup_3.gz_file.png 617w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-backup_3.gz_file-300x72.png 300w\" sizes=\"auto, (max-width: 617px) 100vw, 617px\" \/><\/a><\/figure><\/div>\n\n\n\n<p>Check now the size of the compressed file, it must be considerably less than the &#8220;.tar&#8221; file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"vim\" class=\"language-vim\">ls -lha bkp-wp-content-folder.tar.gz<\/code><\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-backup_4.gz_file_size.png\"><img loading=\"lazy\" decoding=\"async\" width=\"674\" height=\"166\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-backup_4.gz_file_size.png\" alt=\"\" class=\"wp-image-4860\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-backup_4.gz_file_size.png 674w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-backup_4.gz_file_size-300x74.png 300w\" sizes=\"auto, (max-width: 674px) 100vw, 674px\" \/><\/a><\/figure><\/div>\n\n\n\n<p>As you can see the size of the compressed file is <strong>103 Mb<\/strong>, keep in mind that the compression algorithm do their best job over text\/code files but it can&#8217;t do much with images, so if your website has several images the compression step won&#8217;t reduce the file size as much as you may want.<\/p>\n\n\n\n<p>Now that you know the theory behind you can complete both steps, tar and gzip using only one CLI command, see below:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">tar -czf \/var\/www\/bkp-wp-content-folder.tar.gz *<\/code><\/pre>\n\n\n\n<p>And when you want to extract all the files and folders inside the .tar.gz file you can use the following CLI command.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">tar xvzf bkp-wp-content-folder.tar.gz<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3 &#8211; Download compressed file (.tar.gz)<\/h2>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"916\" height=\"512\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-backup-download-compressed-file.gif\" alt=\"\" class=\"wp-image-4864\"\/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Where to go next?<\/h2>\n\n\n\n<p>That&#8217;s it! your WordPress website backup is completed, in case you want to learn how to restore this backup on a local machine, then you can take a look at <a href=\"\/how-to-restore-a-wordpress-backup\/\" target=\"_blank\" rel=\"noreferrer noopener\">this article<\/a>.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-backup_5_completed.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1004\" height=\"334\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-backup_5_completed.png\" alt=\"\" class=\"wp-image-4879\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-backup_5_completed.png 1004w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-backup_5_completed-300x100.png 300w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/04\/wordpress-backup_5_completed-768x255.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/a><figcaption>WordPress website &#8211; backup completed<\/figcaption><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Manual backup vs plugin As you can imagine there are a lot of useful plugins to help you on the task of making a backup of your WordPress website, as always we do have pros and cons when using plugins, in my case and for this particular task I prefer to make backups manually, so, &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/lamp.ciscoar.com\/?page_id=4823\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to backup a WordPress website&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-4823","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/pages\/4823","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4823"}],"version-history":[{"count":38,"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/pages\/4823\/revisions"}],"predecessor-version":[{"id":5744,"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/pages\/4823\/revisions\/5744"}],"wp:attachment":[{"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4823"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}