{"id":819,"date":"2016-02-24T06:08:45","date_gmt":"2016-02-24T06:08:45","guid":{"rendered":"http:\/\/cloudkul.com\/blog\/?p=819"},"modified":"2017-06-14T11:34:08","modified_gmt":"2017-06-14T11:34:08","slug":"e-commerce-sites-automated-backups","status":"publish","type":"post","link":"https:\/\/cloudkul.com\/blog\/e-commerce-sites-automated-backups\/","title":{"rendered":"E-Commerce Sites Automated Backups"},"content":{"rendered":"<p>As many of the developers host their e-commerce sites locally or on cloud, they\u00a0are\u00a0required to take the backup of their applications\u00a0on some remote location so that they may recover their data if any type of \u00a0failure occur and can make their websites available to everyone soon after the downtime. Although many of the e-commerce sites frameworks such as magento, joomla etc provide backup functionality at their own but it requires you to login to the console,navigate to the backup page, click the backup button, wait for the backup to finish and then download the backup. Moreover, you might not be familiar enough with this backup procedure as it may differ from framework to framework.<\/p>\n<p>What if we provide you a better way to automate the complete backup of your e-commerce website on daily basis and store them on some remote location. This requirement includes a simple bash script, FTP connection to destination location where you want to store your backup and setting up cron jobs in order to automate them. Here we go !<\/p>\n<p><strong>STEP1-Login Without Password :<\/strong> Since we want to completely automate the process using cron job, it requires that the backup script won&#8217;t ask for password at run time to store the backup at destination location. For this, we must be able to access the destination location from our local system without password. We have multiple ways to do so, the first way is to\u00a0<a href=\"http:\/\/cloudkul.com\/blog\/securely-connecting-to-server-without-password-authentication-ssh-sftp\/\">login using pem files<\/a>\u00a0and the other way is to place your public key into destination&#8217;s authorized keys.Here, we will describe the latter one.<\/p>\n<p>Generate public key :<\/p>\n<pre class=\"lang:default decode:true\">ssh-keygen -b 1024 -t rsa<\/pre>\n<p>The generated public key is stored in \/home\/users\/username\/.ssh\/id_rsa.pub.Place your public key into destination&#8217;s authorized_keys :<\/p>\n<pre class=\"lang:default decode:true\">cat\u00a0.ssh\/id_rsa.pub\u00a0| ssh username@destinationIP \u00a0'cat &gt;&gt; .ssh\/authorized_keys'<\/pre>\n<p>This command will prompt you for the password if you are trying to connect for the very first time, and then it will place your public key into destination&#8217;s authorized keys. Now, everytime you want to ssh\/scp the destination location from your local system, it won&#8217;t prompt you for password since the destination location now recongnizes your public key.<\/p>\n<p><strong>STEP2-Write The Backup Script :<\/strong><\/p>\n<p>Create a simple bash script named mysite_backup.sh inside your home directory i.e. \/home\/username\/mysite_backup.sh and paste the following content :-<\/p>\n<pre class=\"lang:default decode:true\">nano\u00a0mysite_backup.sh<\/pre>\n<pre class=\"lang:default decode:true  \">sfolder=\"NULL\" #mention the Source folder's complete path e.g \/var\/www\/magento\r\nusername=\"NULL\" #Username of Your Destination System\r\ndip=\"NULL\" # Destination IP where you want to store your backup\r\nmysqluser=\"NULL\" #Mysql Username used in your application\r\ndbname=\"NULL\" #Mention the Database Name used in your application\r\nextension=\".sql\" #Do not change it\r\nscp -r $sfolder $username@$dip:\/home\/$username\/www\/\r\nmysqldump -u$mysqluser -p$dbpassword $dbname &gt; $dbname$extension \r\nscp -r $dbname$extension $username@$dip:\/home\/$username\/www\/\r\n\r\n<\/pre>\n<p><strong>STEP3-Setup Cron :\u00a0<\/strong>The final step is to run this script on regular basis which requires to setup a cron job. Run the following command :-<\/p>\n<pre class=\"lang:default decode:true \">crontab -e\r\n<\/pre>\n<p>Suppose you want to run this script everyday at 9 pm (this may change according to your requirement), add the following in the last line :-<\/p>\n<p>0 \u00a021 \u00a0 * \u00a0* \u00a0* \u00a0$pathtoscript\/cpanel_backup.sh<\/p>\n<pre class=\"lang:default decode:true\">0 \u00a021 \u00a0 * \u00a0* \u00a0* \u00a0\/home\/users\/username\/cpanel_backup.sh<\/pre>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/cloudkul.com\/contact\/\" target=\"_blank\">IN CASE OF ANY QUERY, PLEASE CONTACT US<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As many of the developers host their e-commerce sites locally or on cloud, they\u00a0are\u00a0required to <a class=\"text-primary\" title=\"read more\" href=\"https:\/\/cloudkul.com\/blog\/e-commerce-sites-automated-backups\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":5,"featured_media":839,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>E-Commerce Sites Automated Backups - Cloudkul<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cloudkul.com\/blog\/e-commerce-sites-automated-backups\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"E-Commerce Sites Automated Backups - Cloudkul\" \/>\n<meta property=\"og:description\" content=\"As many of the developers host their e-commerce sites locally or on cloud, they\u00a0are\u00a0required to [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cloudkul.com\/blog\/e-commerce-sites-automated-backups\/\" \/>\n<meta property=\"og:site_name\" content=\"Cloudkul\" \/>\n<meta property=\"article:published_time\" content=\"2016-02-24T06:08:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-06-14T11:34:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2016\/02\/Cpanel-Automated-Backup-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"848\" \/>\n\t<meta property=\"og:image:height\" content=\"422\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Naina Johari\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cloudkul.com\/blog\/e-commerce-sites-automated-backups\/\",\"url\":\"https:\/\/cloudkul.com\/blog\/e-commerce-sites-automated-backups\/\",\"name\":\"E-Commerce Sites Automated Backups - Cloudkul\",\"isPartOf\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/#website\"},\"datePublished\":\"2016-02-24T06:08:45+00:00\",\"dateModified\":\"2017-06-14T11:34:08+00:00\",\"author\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/38f7cddff574c7fe989d6ca2df61fc57\"},\"breadcrumb\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/e-commerce-sites-automated-backups\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cloudkul.com\/blog\/e-commerce-sites-automated-backups\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cloudkul.com\/blog\/e-commerce-sites-automated-backups\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cloudkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"E-Commerce Sites Automated Backups\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#website\",\"url\":\"https:\/\/cloudkul.com\/blog\/\",\"name\":\"Cloudkul\",\"description\":\"Host your eCommerce Store on AWS with Optimized Performance\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cloudkul.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/38f7cddff574c7fe989d6ca2df61fc57\",\"name\":\"Naina Johari\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c7a0be3afff58963975900f809e57046?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c7a0be3afff58963975900f809e57046?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g\",\"caption\":\"Naina Johari\"},\"url\":\"https:\/\/cloudkul.com\/blog\/author\/naina-johari379\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"E-Commerce Sites Automated Backups - Cloudkul","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cloudkul.com\/blog\/e-commerce-sites-automated-backups\/","og_locale":"en_US","og_type":"article","og_title":"E-Commerce Sites Automated Backups - Cloudkul","og_description":"As many of the developers host their e-commerce sites locally or on cloud, they\u00a0are\u00a0required to [...]","og_url":"https:\/\/cloudkul.com\/blog\/e-commerce-sites-automated-backups\/","og_site_name":"Cloudkul","article_published_time":"2016-02-24T06:08:45+00:00","article_modified_time":"2017-06-14T11:34:08+00:00","og_image":[{"width":848,"height":422,"url":"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2016\/02\/Cpanel-Automated-Backup-1.png","type":"image\/png"}],"author":"Naina Johari","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/cloudkul.com\/blog\/e-commerce-sites-automated-backups\/","url":"https:\/\/cloudkul.com\/blog\/e-commerce-sites-automated-backups\/","name":"E-Commerce Sites Automated Backups - Cloudkul","isPartOf":{"@id":"https:\/\/cloudkul.com\/blog\/#website"},"datePublished":"2016-02-24T06:08:45+00:00","dateModified":"2017-06-14T11:34:08+00:00","author":{"@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/38f7cddff574c7fe989d6ca2df61fc57"},"breadcrumb":{"@id":"https:\/\/cloudkul.com\/blog\/e-commerce-sites-automated-backups\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cloudkul.com\/blog\/e-commerce-sites-automated-backups\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/cloudkul.com\/blog\/e-commerce-sites-automated-backups\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cloudkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"E-Commerce Sites Automated Backups"}]},{"@type":"WebSite","@id":"https:\/\/cloudkul.com\/blog\/#website","url":"https:\/\/cloudkul.com\/blog\/","name":"Cloudkul","description":"Host your eCommerce Store on AWS with Optimized Performance","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cloudkul.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/38f7cddff574c7fe989d6ca2df61fc57","name":"Naina Johari","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c7a0be3afff58963975900f809e57046?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c7a0be3afff58963975900f809e57046?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g","caption":"Naina Johari"},"url":"https:\/\/cloudkul.com\/blog\/author\/naina-johari379\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/819"}],"collection":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/comments?post=819"}],"version-history":[{"count":23,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/819\/revisions"}],"predecessor-version":[{"id":847,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/819\/revisions\/847"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/media\/839"}],"wp:attachment":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/media?parent=819"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/categories?post=819"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/tags?post=819"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}