{"id":288,"date":"2017-12-15T19:09:05","date_gmt":"2017-12-15T18:09:05","guid":{"rendered":"https:\/\/mindau.de\/blog\/?p=288"},"modified":"2019-01-26T22:45:10","modified_gmt":"2019-01-26T21:45:10","slug":"auto-webserver-and-database-backup-with-gpg-encryption-to-amazon-s3","status":"publish","type":"post","link":"https:\/\/mindau.de\/blog\/en\/auto-webserver-and-database-backup-with-gpg-encryption-to-amazon-s3\/","title":{"rendered":"Auto webserver and database backup with GPG encryption to Amazon S3"},"content":{"rendered":"<blockquote><p>In this tutorial I will show you step-by-step\u00a0 instructions how to make cheap and secure encrypted backups of you webserver (or any other dir)\u00a0 files on you linux\u00a0 server using Amazon Storage Service<\/p><\/blockquote>\n<p><!--more--><\/p>\n<h2>Create Bucket and User at Amazon AWS<\/h2>\n<p>Some links that we will need<\/p>\n<ul>\n<li>Amazon Console link &#8211; https:\/\/aws.amazon.com\/<\/li>\n<li>Amazon S3 &#8211; <a href=\"https:\/\/console.aws.amazon.com\/iam\">https:\/\/s3.console.aws.amazon.com\/s3<\/a><\/li>\n<li>Amazon IAM &#8211;<a href=\"https:\/\/console.aws.amazon.com\/iam\"> https:\/\/console.aws.amazon.com\/iam<\/a><\/li>\n<\/ul>\n<p>Firstly create an user at <a href=\"https:\/\/console.aws.amazon.com\/iam\"><strong>Amazon IAM<\/strong><\/a> managment console. Don&#8217;t forget to set permision &#8211; <span class=\"awsui-tooltip awsui-tooltip-no-slide awsui-tooltip-right awsui-tooltip-rounded awsui-tooltip-size-auto\" aria-label=\"AmazonS3FullAccess\" data-awsui-tooltip-text=\"AmazonS3FullAccess\"> <span class=\"ng-scope system-policy-name\"><strong> AmazonS3FullAccess. <\/strong>Copy your access and secret keys. You will need it later<\/span><\/span><\/p>\n<p>Now create a bucket for a backups at <strong><a href=\"https:\/\/s3.console.aws.amazon.com\/s3\">Amazon S3<\/a>. <\/strong>For testing you can leave all settings by default.<\/p>\n<h2>Install AWS CLI tools on your server machine<\/h2>\n<p>Now you can install Amazon AWS command line interface. For that you will need<strong> Python and Pip<\/strong>. If you don&#8217;t have it, you can found\u00a0 a very nice tutorial <a href=\"https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-install-python-3-and-set-up-a-programming-environment-on-an-ubuntu-16-04-server\">here<\/a> .<\/p>\n<pre class=\"lang:default decode:true\">pip install awscli --upgrade --user\n\n<\/pre>\n<p>You may need to export path where aws was installed .<\/p>\n<pre class=\"lang:default decode:true\"># Try\nwhich aws\n\/root\/.local\/bin\/aws\n<\/pre>\n<p>Add the executable path to your PATH variable: <code>~\/.local\/bin<\/code><\/p>\n<pre class=\"lang:default decode:true \">export PATH=~\/.local\/bin:$PATH\nsource ~\/.bash_profile<\/pre>\n<p>Configurate access to <strong>Amazon S3<\/strong>. Use your access keys from IAM.<span class=\"awsui-tooltip awsui-tooltip-no-slide awsui-tooltip-right awsui-tooltip-rounded awsui-tooltip-size-auto\" aria-label=\"AmazonS3FullAccess\" data-awsui-tooltip-text=\"AmazonS3FullAccess\"><span class=\"ng-scope system-policy-name\"> Also you will need Amazon region string. You can find it <a href=\"http:\/\/docs.aws.amazon.com\/en_en\/general\/latest\/gr\/rande.html\">here<\/a><\/span><\/span><\/p>\n<pre class=\"lang:default decode:true\">aws configure \n\nAWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE \nAWS Secret Access Key [None]: wJalrXUtnFEMI\/K7MDENG\/bPxRfiCYEXAMPLEKEY \nDefault region name [None]: eu-central-1 \nDefault output format [None]: json<\/pre>\n<p>Now you can test if you can copy any files to your bucket<\/p>\n<pre class=\"lang:default decode:true\"># show available buckets\naws s3 ls\n\n#copy file to bucket\naws s3 cp test_file.txt s3:\/\/mybucketname<\/pre>\n<h2>Creating Database and Webserver backup with encryption<\/h2>\n<p>Create a backup shell script file. If you get an error, try to run with sudo<\/p>\n<pre class=\"lang:default decode:true \">curl -o \/usr\/local\/bin\/backup.sh https:\/\/gist.githubusercontent.com\/grambas\/6950da61b5ad31185931ddb2c0f9ecab\/raw\/backup.sh\n<\/pre>\n<p>Content of backup.sh<\/p>\n<style>.gist table { margin-bottom: 0; }<\/style>\n<div style=\"tab-size: 8\" id=\"gist47965762\" class=\"gist\">\n<div class=\"gist-file\" translate=\"no\" data-color-mode=\"light\" data-light-theme=\"light\">\n<div class=\"gist-data\">\n<div class=\"js-gist-file-update-container js-task-list-container\">\n<div id=\"file-backup-sh\" class=\"file my-2\">\n<div itemprop=\"text\"\n      class=\"Box-body p-0 blob-wrapper data type-shell  \"\n      style=\"overflow: auto\" tabindex=\"0\" role=\"region\"\n      aria-label=\"backup.sh content, created by grambas on 01:31PM on May 23, 2017.\"\n    ><\/p>\n<div class=\"js-check-hidden-unicode js-blob-code-container blob-code-content\">\n<p>  <template class=\"js-file-alert-template\"><\/p>\n<div data-view-component=\"true\" class=\"flash flash-warn flash-full d-flex flex-items-center\">\n  <svg aria-hidden=\"true\" height=\"16\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" data-view-component=\"true\" class=\"octicon octicon-alert\">\n    <path d=\"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z\"><\/path>\n<\/svg><br \/>\n    <span><br \/>\n      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.<br \/>\n      <a class=\"Link--inTextBlock\" href=\"https:\/\/github.co\/hiddenchars\" target=\"_blank\">Learn more about bidirectional Unicode characters<\/a><br \/>\n    <\/span><\/p>\n<div data-view-component=\"true\" class=\"flash-action\">        <a href=\"{{ revealButtonHref }}\" data-view-component=\"true\" class=\"btn-sm btn\">    Show hidden characters<br \/>\n<\/a>\n<\/div>\n<\/div>\n<p><\/template><br \/>\n<template class=\"js-line-alert-template\"><br \/>\n  <span aria-label=\"This line has hidden Unicode characters\" data-view-component=\"true\" class=\"line-alert tooltipped tooltipped-e\"><br \/>\n    <svg aria-hidden=\"true\" height=\"16\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" data-view-component=\"true\" class=\"octicon octicon-alert\">\n    <path d=\"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z\"><\/path>\n<\/svg><br \/>\n<\/span><\/template><\/p>\n<table data-hpc class=\"highlight tab-size js-file-line-container\" data-tab-size=\"4\" data-paste-markdown-skip data-tagsearch-path=\"backup.sh\">\n<tr>\n<td id=\"file-backup-sh-L1\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"1\"><\/td>\n<td id=\"file-backup-sh-LC1\" class=\"blob-code blob-code-inner js-file-line\"> #!\/bin\/bash<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L2\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"2\"><\/td>\n<td id=\"file-backup-sh-LC2\" class=\"blob-code blob-code-inner js-file-line\"># Execute it as root, due to archiving permision conflicts<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L3\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"3\"><\/td>\n<td id=\"file-backup-sh-LC3\" class=\"blob-code blob-code-inner js-file-line\">#CRONTAB entry for every day at 04:00 AM<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L4\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"4\"><\/td>\n<td id=\"file-backup-sh-LC4\" class=\"blob-code blob-code-inner js-file-line\">#0 4 * * * \/usr\/local\/bin\/webserver-backup.sh &gt;\/dev\/null 2&gt;&amp;1<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L5\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"5\"><\/td>\n<td id=\"file-backup-sh-LC5\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L6\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"6\"><\/td>\n<td id=\"file-backup-sh-LC6\" class=\"blob-code blob-code-inner js-file-line\"># DATABSE DATA<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L7\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"7\"><\/td>\n<td id=\"file-backup-sh-LC7\" class=\"blob-code blob-code-inner js-file-line\">DB_USER=&quot;XXX&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L8\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"8\"><\/td>\n<td id=\"file-backup-sh-LC8\" class=\"blob-code blob-code-inner js-file-line\">DB_PASSWORD=&quot;XXX&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L9\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"9\"><\/td>\n<td id=\"file-backup-sh-LC9\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L10\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"10\"><\/td>\n<td id=\"file-backup-sh-LC10\" class=\"blob-code blob-code-inner js-file-line\"># PATH&#39;S<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L11\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"11\"><\/td>\n<td id=\"file-backup-sh-LC11\" class=\"blob-code blob-code-inner js-file-line\">OUTPUT_PATH=&quot;\/srv\/backup&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L12\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"12\"><\/td>\n<td id=\"file-backup-sh-LC12\" class=\"blob-code blob-code-inner js-file-line\">WWW_PATH=&quot;\/srv\/webserver&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L13\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"13\"><\/td>\n<td id=\"file-backup-sh-LC13\" class=\"blob-code blob-code-inner js-file-line\">TEMP_PATH=&quot;\/srv\/backup\/temp&quot; #where to store data temporary before archiving and encrypting<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L14\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"14\"><\/td>\n<td id=\"file-backup-sh-LC14\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L15\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"15\"><\/td>\n<td id=\"file-backup-sh-LC15\" class=\"blob-code blob-code-inner js-file-line\"># FTP DATA (where to save backup)<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L16\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"16\"><\/td>\n<td id=\"file-backup-sh-LC16\" class=\"blob-code blob-code-inner js-file-line\">FTP_LOGIN=&quot;XXX&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L17\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"17\"><\/td>\n<td id=\"file-backup-sh-LC17\" class=\"blob-code blob-code-inner js-file-line\">FTP_PASS=&quot;XXX&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L18\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"18\"><\/td>\n<td id=\"file-backup-sh-LC18\" class=\"blob-code blob-code-inner js-file-line\">REMOTE_PATH=&quot;BACKUPS\/WEBSERVER\/&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L19\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"19\"><\/td>\n<td id=\"file-backup-sh-LC19\" class=\"blob-code blob-code-inner js-file-line\">REMOTE_HOST=&quot;77.23.XXZ.XX&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L20\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"20\"><\/td>\n<td id=\"file-backup-sh-LC20\" class=\"blob-code blob-code-inner js-file-line\">PORT=&quot;21&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L21\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"21\"><\/td>\n<td id=\"file-backup-sh-LC21\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L22\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"22\"><\/td>\n<td id=\"file-backup-sh-LC22\" class=\"blob-code blob-code-inner js-file-line\"># OTHER CONSTS<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L23\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"23\"><\/td>\n<td id=\"file-backup-sh-LC23\" class=\"blob-code blob-code-inner js-file-line\">DATE=`date +%Y-%m-%d`<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L24\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"24\"><\/td>\n<td id=\"file-backup-sh-LC24\" class=\"blob-code blob-code-inner js-file-line\">LOG_DATE=`date +[%Y-%m-%d:%H:%M:%S]`<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L25\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"25\"><\/td>\n<td id=\"file-backup-sh-LC25\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L26\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"26\"><\/td>\n<td id=\"file-backup-sh-LC26\" class=\"blob-code blob-code-inner js-file-line\"># create directory if not exist<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L27\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"27\"><\/td>\n<td id=\"file-backup-sh-LC27\" class=\"blob-code blob-code-inner js-file-line\">mkdir -p &quot;$TEMP_PATH&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L28\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"28\"><\/td>\n<td id=\"file-backup-sh-LC28\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L29\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"29\"><\/td>\n<td id=\"file-backup-sh-LC29\" class=\"blob-code blob-code-inner js-file-line\"># remove old backup data at webserver in case error occurred during upload.<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L30\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"30\"><\/td>\n<td id=\"file-backup-sh-LC30\" class=\"blob-code blob-code-inner js-file-line\">rm -f $TEMP_PATH\/*.sql &gt; \/dev\/null 2&gt;&amp;1<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L31\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"31\"><\/td>\n<td id=\"file-backup-sh-LC31\" class=\"blob-code blob-code-inner js-file-line\">rm -f $OUTPUT_PATH\/*.tar.gz &gt; \/dev\/null 2&gt;&amp;1<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L32\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"32\"><\/td>\n<td id=\"file-backup-sh-LC32\" class=\"blob-code blob-code-inner js-file-line\">rm -f $OUTPUT_PATH\/*.tar.gz.asc &gt; \/dev\/null 2&gt;&amp;1<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L33\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"33\"><\/td>\n<td id=\"file-backup-sh-LC33\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L34\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"34\"><\/td>\n<td id=\"file-backup-sh-LC34\" class=\"blob-code blob-code-inner js-file-line\"># get database table names<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L35\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"35\"><\/td>\n<td id=\"file-backup-sh-LC35\" class=\"blob-code blob-code-inner js-file-line\">databases=`mysql &#8211;user=$DB_USER &#8211;password=$DB_PASSWORD -e &quot;SHOW DATABASES;&quot; | tr -d &quot;| &quot; | grep -v Database`<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L36\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"36\"><\/td>\n<td id=\"file-backup-sh-LC36\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L37\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"37\"><\/td>\n<td id=\"file-backup-sh-LC37\" class=\"blob-code blob-code-inner js-file-line\">echo &quot;$LOG_DATE DUMPING DATABASE TABLES&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L38\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"38\"><\/td>\n<td id=\"file-backup-sh-LC38\" class=\"blob-code blob-code-inner js-file-line\">for db in $databases; do<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L39\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"39\"><\/td>\n<td id=\"file-backup-sh-LC39\" class=\"blob-code blob-code-inner js-file-line\">\t# Ignore default phpmyadmin tables<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L40\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"40\"><\/td>\n<td id=\"file-backup-sh-LC40\" class=\"blob-code blob-code-inner js-file-line\">    if [[ &quot;$db&quot; != &quot;information_schema&quot; ]] &amp;&amp; [[ &quot;$db&quot; != _* ]] &amp;&amp; [[ &quot;$db&quot; != mysql* ]] &amp;&amp; [[ &quot;$db&quot; != &quot;performance_schema&quot; ]] ; then<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L41\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"41\"><\/td>\n<td id=\"file-backup-sh-LC41\" class=\"blob-code blob-code-inner js-file-line\">        name=$TEMP_PATH\/$DATE-$db<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L42\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"42\"><\/td>\n<td id=\"file-backup-sh-LC42\" class=\"blob-code blob-code-inner js-file-line\">        echo &quot;$LOG_DATE Dumped: $name&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L43\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"43\"><\/td>\n<td id=\"file-backup-sh-LC43\" class=\"blob-code blob-code-inner js-file-line\">\t\tmysqldump &#8211;force &#8211;opt &#8211;user=$DB_USER &#8211;password=$DB_PASSWORD &#8211;databases $db &gt; $name.sql<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L44\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"44\"><\/td>\n<td id=\"file-backup-sh-LC44\" class=\"blob-code blob-code-inner js-file-line\">    fi<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L45\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"45\"><\/td>\n<td id=\"file-backup-sh-LC45\" class=\"blob-code blob-code-inner js-file-line\">done<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L46\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"46\"><\/td>\n<td id=\"file-backup-sh-LC46\" class=\"blob-code blob-code-inner js-file-line\">echo &quot;$LOG_DATE DONE!&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L47\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"47\"><\/td>\n<td id=\"file-backup-sh-LC47\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L48\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"48\"><\/td>\n<td id=\"file-backup-sh-LC48\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L49\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"49\"><\/td>\n<td id=\"file-backup-sh-LC49\" class=\"blob-code blob-code-inner js-file-line\"># arhive dumped sql&#39;s and webserver directories<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L50\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"50\"><\/td>\n<td id=\"file-backup-sh-LC50\" class=\"blob-code blob-code-inner js-file-line\">echo &quot;$LOG_DATE Archieving data&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L51\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"51\"><\/td>\n<td id=\"file-backup-sh-LC51\" class=\"blob-code blob-code-inner js-file-line\">tar -czf $OUTPUT_PATH\/$DATE-webserver.tar.gz -C $TEMP_PATH . -C $WWW_PATH .<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L52\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"52\"><\/td>\n<td id=\"file-backup-sh-LC52\" class=\"blob-code blob-code-inner js-file-line\">echo &quot;$LOG_DATE DONE!&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L53\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"53\"><\/td>\n<td id=\"file-backup-sh-LC53\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L54\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"54\"><\/td>\n<td id=\"file-backup-sh-LC54\" class=\"blob-code blob-code-inner js-file-line\"># ENCRYPT archive<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L55\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"55\"><\/td>\n<td id=\"file-backup-sh-LC55\" class=\"blob-code blob-code-inner js-file-line\"># gpg -e -u &quot;Sender User Name&quot; -r &quot;Receiver User Name&quot; somefile<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L56\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"56\"><\/td>\n<td id=\"file-backup-sh-LC56\" class=\"blob-code blob-code-inner js-file-line\"># &#8211;yes auto overwrite<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L57\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"57\"><\/td>\n<td id=\"file-backup-sh-LC57\" class=\"blob-code blob-code-inner js-file-line\">echo &quot;$LOG_DATE ENCRYPTING WEBSERVER&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L58\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"58\"><\/td>\n<td id=\"file-backup-sh-LC58\" class=\"blob-code blob-code-inner js-file-line\">\/usr\/bin\/gpg &#8211;yes -e -a -r &quot;mindaugas&quot; $OUTPUT_PATH\/$DATE-webserver.tar.gz<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L59\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"59\"><\/td>\n<td id=\"file-backup-sh-LC59\" class=\"blob-code blob-code-inner js-file-line\"># remove archived after encryption<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L60\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"60\"><\/td>\n<td id=\"file-backup-sh-LC60\" class=\"blob-code blob-code-inner js-file-line\">rm -f $OUTPUT_PATH\/*.tar.gz &gt; \/dev\/null 2&gt;&amp;1<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L61\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"61\"><\/td>\n<td id=\"file-backup-sh-LC61\" class=\"blob-code blob-code-inner js-file-line\">echo &quot;$LOG_DATE DONE!&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L62\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"62\"><\/td>\n<td id=\"file-backup-sh-LC62\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L63\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"63\"><\/td>\n<td id=\"file-backup-sh-LC63\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L64\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"64\"><\/td>\n<td id=\"file-backup-sh-LC64\" class=\"blob-code blob-code-inner js-file-line\">echo &quot;$LOG_DATE UPLOADING TO REMOTE FTP&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L65\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"65\"><\/td>\n<td id=\"file-backup-sh-LC65\" class=\"blob-code blob-code-inner js-file-line\">sudo curl -T $OUTPUT_PATH\/$DATE-webserver.tar.gz.asc ftp:\/\/$REMOTE_HOST:$PORT\/$REMOTE_PATH\/ &#8211;user $FTP_LOGIN:$FTP_PASS<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L66\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"66\"><\/td>\n<td id=\"file-backup-sh-LC66\" class=\"blob-code blob-code-inner js-file-line\">echo &quot;$LOG_DATE DONE!&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L67\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"67\"><\/td>\n<td id=\"file-backup-sh-LC67\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L68\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"68\"><\/td>\n<td id=\"file-backup-sh-LC68\" class=\"blob-code blob-code-inner js-file-line\"> <\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L69\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"69\"><\/td>\n<td id=\"file-backup-sh-LC69\" class=\"blob-code blob-code-inner js-file-line\"># CHECK IF BACKUP EXIST IN REMOTE FTP<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L70\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"70\"><\/td>\n<td id=\"file-backup-sh-LC70\" class=\"blob-code blob-code-inner js-file-line\">if curl $OUTPUT_PATH\/$DATE-webserver.tar.gz.asc ftp:\/\/$REMOTE_HOST:$PORT\/$REMOTE_PATH\/ -s | grep $DATE-webserver.tar.gz.asc; then<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L71\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"71\"><\/td>\n<td id=\"file-backup-sh-LC71\" class=\"blob-code blob-code-inner js-file-line\">\techo &quot;$LOG_DATE ENCRYPTED ARCHIVE SUCCESFULLY UPLOADED!&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L72\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"72\"><\/td>\n<td id=\"file-backup-sh-LC72\" class=\"blob-code blob-code-inner js-file-line\">\techo &quot;$LOG_DATE DELETING TEMP DATA&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L73\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"73\"><\/td>\n<td id=\"file-backup-sh-LC73\" class=\"blob-code blob-code-inner js-file-line\">\trm -f $TEMP_PATH\/*.sql &gt; \/dev\/null 2&gt;&amp;1<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L74\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"74\"><\/td>\n<td id=\"file-backup-sh-LC74\" class=\"blob-code blob-code-inner js-file-line\">\trm -f $OUTPUT_PATH\/*.tar.gz &gt; \/dev\/null 2&gt;&amp;1<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L75\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"75\"><\/td>\n<td id=\"file-backup-sh-LC75\" class=\"blob-code blob-code-inner js-file-line\">\trm -f $OUTPUT_PATH\/*.tar.gz.asc &gt; \/dev\/null 2&gt;&amp;1<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L76\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"76\"><\/td>\n<td id=\"file-backup-sh-LC76\" class=\"blob-code blob-code-inner js-file-line\">\techo &quot;$LOG_DATE DONE!&quot;cronmt<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L77\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"77\"><\/td>\n<td id=\"file-backup-sh-LC77\" class=\"blob-code blob-code-inner js-file-line\">\techo &quot;$LOG_DATE DO WEBSERVER BACKUP SUCCESS!&quot; | \/usr\/local\/bin\/slackpost.sh<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L78\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"78\"><\/td>\n<td id=\"file-backup-sh-LC78\" class=\"blob-code blob-code-inner js-file-line\">else<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L79\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"79\"><\/td>\n<td id=\"file-backup-sh-LC79\" class=\"blob-code blob-code-inner js-file-line\">  echo &quot;$LOG_DATE [ERROR] NO BACKUP WAS FOUND AFTER UPLOAD!&quot; | \/usr\/local\/bin\/slackpost.sh<\/td>\n<\/tr>\n<tr>\n<td id=\"file-backup-sh-L80\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"80\"><\/td>\n<td id=\"file-backup-sh-LC80\" class=\"blob-code blob-code-inner js-file-line\">fi<\/td>\n<\/tr>\n<\/table>\n<\/div><\/div>\n<\/p><\/div>\n<\/div><\/div>\n<div class=\"gist-meta\">\n        <a href=\"https:\/\/gist.github.com\/grambas\/71642fb9bebabd5010d5dacc05af9953\/raw\/4438ff6aba630392e978fecf987bbbe3938c06aa\/backup.sh\" style=\"float:right\" class=\"Link--inTextBlock\">view raw<\/a><br \/>\n        <a href=\"https:\/\/gist.github.com\/grambas\/71642fb9bebabd5010d5dacc05af9953#file-backup-sh\" class=\"Link--inTextBlock\"><br \/>\n          backup.sh<br \/>\n        <\/a><br \/>\n        hosted with &#10084; by <a class=\"Link--inTextBlock\" href=\"https:\/\/github.com\">GitHub<\/a>\n      <\/div>\n<\/p><\/div>\n<\/div>\n<p>Set the excecution permision on backup.sh<\/p>\n<pre class=\"lang:default decode:true\">chmod +x \/usr\/local\/bin\/backup.sh<\/pre>\n<p>Create log file (feel free to change the path) and open\u00a0 Crontab window<\/p>\n<pre class=\"lang:default decode:true\">touch \/srv\/backup\/cronlog.log\ncrontrab -e<\/pre>\n<p>Add the following text to the end of crontab file (there is <a href=\"https:\/\/crontab-generator.org\/\">Crontab Generator<\/a>, where you can easily set your execution schedule).<\/p>\n<pre class=\"lang:default decode:true\">#crontab does not have path so we add it manualy\nSHELL=\/bin\/sh\nPATH=\/usr\/local\/sbin:\/usr\/local\/bin:\/sbin:\/bin:\/usr\/sbin:\/usr\/bin:\/root\/.local\/bin\n\n#This is crontab entry CRONTAB example. Backup daily at 04:00 AM\n0 4 * * * \/usr\/local\/bin\/backup.sh &gt; \/srv\/backup\/cronlog.log 2&gt;&amp;1<\/pre>\n<p>Just in case , test you script<\/p>\n<pre class=\"lang:default decode:true\">backup.sh<\/pre>\n<p>Sure later you may need to decrypt it<\/p>\n<pre class=\"lang:default decode:true \">gpg --output decrypted.tar.gz --decrypt encrypted.tar.gz.asc<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial I will show you step-by-step\u00a0 instructions how to make cheap and secure encrypted backups of you webserver (or any other dir)\u00a0 files on you linux\u00a0 server using Amazon Storage Service<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[5,11,14,16],"tags":[],"jetpack_publicize_connections":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Auto webserver and database backup with GPG encryption to Amazon S3 - Mindau | Blog<\/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:\/\/mindau.de\/blog\/en\/auto-webserver-and-database-backup-with-gpg-encryption-to-amazon-s3\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Auto webserver and database backup with GPG encryption to Amazon S3 - Mindau | Blog\" \/>\n<meta property=\"og:description\" content=\"In this tutorial I will show you step-by-step\u00a0 instructions how to make cheap and secure encrypted backups of you webserver (or any other dir)\u00a0 files on you linux\u00a0 server using Amazon Storage Service\" \/>\n<meta property=\"og:url\" content=\"https:\/\/mindau.de\/blog\/en\/auto-webserver-and-database-backup-with-gpg-encryption-to-amazon-s3\/\" \/>\n<meta property=\"og:site_name\" content=\"Mindau | Blog\" \/>\n<meta property=\"article:published_time\" content=\"2017-12-15T18:09:05+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-01-26T21:45:10+00:00\" \/>\n<meta name=\"author\" content=\"Mindau\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@MindaugasMilius\" \/>\n<meta name=\"twitter:site\" content=\"@MindaugasMilius\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mindau\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/mindau.de\/blog\/en\/auto-webserver-and-database-backup-with-gpg-encryption-to-amazon-s3\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/mindau.de\/blog\/en\/auto-webserver-and-database-backup-with-gpg-encryption-to-amazon-s3\/\"},\"author\":{\"name\":\"Mindau\",\"@id\":\"https:\/\/mindau.de\/blog\/#\/schema\/person\/b59ad18a46b5a55b9319b41779682998\"},\"headline\":\"Auto webserver and database backup with GPG encryption to Amazon S3\",\"datePublished\":\"2017-12-15T18:09:05+00:00\",\"dateModified\":\"2019-01-26T21:45:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/mindau.de\/blog\/en\/auto-webserver-and-database-backup-with-gpg-encryption-to-amazon-s3\/\"},\"wordCount\":316,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/mindau.de\/blog\/#\/schema\/person\/b59ad18a46b5a55b9319b41779682998\"},\"articleSection\":[\"English\",\"Linux\",\"Tutorials\",\"Webserver\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/mindau.de\/blog\/en\/auto-webserver-and-database-backup-with-gpg-encryption-to-amazon-s3\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/mindau.de\/blog\/en\/auto-webserver-and-database-backup-with-gpg-encryption-to-amazon-s3\/\",\"url\":\"https:\/\/mindau.de\/blog\/en\/auto-webserver-and-database-backup-with-gpg-encryption-to-amazon-s3\/\",\"name\":\"Auto webserver and database backup with GPG encryption to Amazon S3 - Mindau | Blog\",\"isPartOf\":{\"@id\":\"https:\/\/mindau.de\/blog\/#website\"},\"datePublished\":\"2017-12-15T18:09:05+00:00\",\"dateModified\":\"2019-01-26T21:45:10+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/mindau.de\/blog\/en\/auto-webserver-and-database-backup-with-gpg-encryption-to-amazon-s3\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/mindau.de\/blog\/en\/auto-webserver-and-database-backup-with-gpg-encryption-to-amazon-s3\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/mindau.de\/blog\/en\/auto-webserver-and-database-backup-with-gpg-encryption-to-amazon-s3\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/mindau.de\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Auto webserver and database backup with GPG encryption to Amazon S3\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/mindau.de\/blog\/#website\",\"url\":\"https:\/\/mindau.de\/blog\/\",\"name\":\"Mindau | Blog\",\"description\":\"Mindaugas Milius\",\"publisher\":{\"@id\":\"https:\/\/mindau.de\/blog\/#\/schema\/person\/b59ad18a46b5a55b9319b41779682998\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/mindau.de\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/mindau.de\/blog\/#\/schema\/person\/b59ad18a46b5a55b9319b41779682998\",\"name\":\"Mindau\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/mindau.de\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/mindau.de\/blog\/wp-content\/uploads\/2022\/02\/1639431846236.jpeg\",\"contentUrl\":\"https:\/\/mindau.de\/blog\/wp-content\/uploads\/2022\/02\/1639431846236.jpeg\",\"width\":250,\"height\":250,\"caption\":\"Mindau\"},\"logo\":{\"@id\":\"https:\/\/mindau.de\/blog\/#\/schema\/person\/image\/\"},\"sameAs\":[\"http:\/\/mindau.de\",\"https:\/\/www.linkedin.com\/in\/mindaugasmilius\/\",\"https:\/\/twitter.com\/MindaugasMilius\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Auto webserver and database backup with GPG encryption to Amazon S3 - Mindau | Blog","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:\/\/mindau.de\/blog\/en\/auto-webserver-and-database-backup-with-gpg-encryption-to-amazon-s3\/","og_locale":"en_US","og_type":"article","og_title":"Auto webserver and database backup with GPG encryption to Amazon S3 - Mindau | Blog","og_description":"In this tutorial I will show you step-by-step\u00a0 instructions how to make cheap and secure encrypted backups of you webserver (or any other dir)\u00a0 files on you linux\u00a0 server using Amazon Storage Service","og_url":"https:\/\/mindau.de\/blog\/en\/auto-webserver-and-database-backup-with-gpg-encryption-to-amazon-s3\/","og_site_name":"Mindau | Blog","article_published_time":"2017-12-15T18:09:05+00:00","article_modified_time":"2019-01-26T21:45:10+00:00","author":"Mindau","twitter_card":"summary_large_image","twitter_creator":"@MindaugasMilius","twitter_site":"@MindaugasMilius","twitter_misc":{"Written by":"Mindau","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/mindau.de\/blog\/en\/auto-webserver-and-database-backup-with-gpg-encryption-to-amazon-s3\/#article","isPartOf":{"@id":"https:\/\/mindau.de\/blog\/en\/auto-webserver-and-database-backup-with-gpg-encryption-to-amazon-s3\/"},"author":{"name":"Mindau","@id":"https:\/\/mindau.de\/blog\/#\/schema\/person\/b59ad18a46b5a55b9319b41779682998"},"headline":"Auto webserver and database backup with GPG encryption to Amazon S3","datePublished":"2017-12-15T18:09:05+00:00","dateModified":"2019-01-26T21:45:10+00:00","mainEntityOfPage":{"@id":"https:\/\/mindau.de\/blog\/en\/auto-webserver-and-database-backup-with-gpg-encryption-to-amazon-s3\/"},"wordCount":316,"commentCount":0,"publisher":{"@id":"https:\/\/mindau.de\/blog\/#\/schema\/person\/b59ad18a46b5a55b9319b41779682998"},"articleSection":["English","Linux","Tutorials","Webserver"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/mindau.de\/blog\/en\/auto-webserver-and-database-backup-with-gpg-encryption-to-amazon-s3\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/mindau.de\/blog\/en\/auto-webserver-and-database-backup-with-gpg-encryption-to-amazon-s3\/","url":"https:\/\/mindau.de\/blog\/en\/auto-webserver-and-database-backup-with-gpg-encryption-to-amazon-s3\/","name":"Auto webserver and database backup with GPG encryption to Amazon S3 - Mindau | Blog","isPartOf":{"@id":"https:\/\/mindau.de\/blog\/#website"},"datePublished":"2017-12-15T18:09:05+00:00","dateModified":"2019-01-26T21:45:10+00:00","breadcrumb":{"@id":"https:\/\/mindau.de\/blog\/en\/auto-webserver-and-database-backup-with-gpg-encryption-to-amazon-s3\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/mindau.de\/blog\/en\/auto-webserver-and-database-backup-with-gpg-encryption-to-amazon-s3\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/mindau.de\/blog\/en\/auto-webserver-and-database-backup-with-gpg-encryption-to-amazon-s3\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/mindau.de\/blog\/"},{"@type":"ListItem","position":2,"name":"Auto webserver and database backup with GPG encryption to Amazon S3"}]},{"@type":"WebSite","@id":"https:\/\/mindau.de\/blog\/#website","url":"https:\/\/mindau.de\/blog\/","name":"Mindau | Blog","description":"Mindaugas Milius","publisher":{"@id":"https:\/\/mindau.de\/blog\/#\/schema\/person\/b59ad18a46b5a55b9319b41779682998"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/mindau.de\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/mindau.de\/blog\/#\/schema\/person\/b59ad18a46b5a55b9319b41779682998","name":"Mindau","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/mindau.de\/blog\/#\/schema\/person\/image\/","url":"https:\/\/mindau.de\/blog\/wp-content\/uploads\/2022\/02\/1639431846236.jpeg","contentUrl":"https:\/\/mindau.de\/blog\/wp-content\/uploads\/2022\/02\/1639431846236.jpeg","width":250,"height":250,"caption":"Mindau"},"logo":{"@id":"https:\/\/mindau.de\/blog\/#\/schema\/person\/image\/"},"sameAs":["http:\/\/mindau.de","https:\/\/www.linkedin.com\/in\/mindaugasmilius\/","https:\/\/twitter.com\/MindaugasMilius"]}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pcptsa-4E","jetpack-related-posts":[{"id":111,"url":"https:\/\/mindau.de\/blog\/en\/how-to-tutorials\/secure-nginx-configuration\/","url_meta":{"origin":288,"position":0},"title":"Secure Nginx configuration","date":"May 3, 2017","format":false,"excerpt":"After some research and digging, I made my nginx and domain configuration files. If I have something missed, you are welcome to write it in comment here or at Github. Mostly everything are commented so to understand code should be not problem. https:\/\/gist.github.com\/grambas\/a978ae5cdea456a5f8a55796a6cd6e7f#file-nginx-conf UPDATE: If you want more advanced solution,\u2026","rel":"","context":"In &quot;Linux&quot;","img":{"alt_text":"nginx secure configuration","src":"https:\/\/i0.wp.com\/mindau.de\/blog\/wp-content\/uploads\/2017\/05\/nginx-secure-configuration.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":129,"url":"https:\/\/mindau.de\/blog\/lt\/interneto-duomenu-apdorojimas-ir-kiekis-21-mame-amziuje\/","url_meta":{"origin":288,"position":1},"title":"Interneto duomen\u0173 apdorojimas ir kiekis 21-mame am\u017eiuje","date":"May 17, 2017","format":false,"excerpt":"21-sis am\u017eius - skaitmenizacijos am\u017eius. S\u0105skaitos,kontaktiniai adresai, u\u017era\u0161ai, nuotraukos, vaizdo \u012fra\u0161ai, muzikos failai, susitikimai ir dar daugyb\u0117 informacijos klasifikuojama ir saugoma kompiuteriuose, serveriuose ar cloud'uose. Ar kada susim\u0105st\u0117te kiek duomen\u0173 yra persiun\u010diama ar apskritai koks kiekis duomen\u0173 \u0161iais\u00a0\u00a0laikais yra didelis? 2001 metais SanDisk pristat\u0117 savo naujov\u0119\u00a0- atminties kortel\u0119 su 128MB\u2026","rel":"","context":"In &quot;Lietuvi\u0173 k.&quot;","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mindau.de\/blog\/wp-content\/uploads\/2017\/05\/ball-63527_1920.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":72,"url":"https:\/\/mindau.de\/blog\/en\/en-post-messages-slack-linux\/","url_meta":{"origin":288,"position":2},"title":"[EN] Post messages to slack from linux","date":"April 27, 2017","format":false,"excerpt":"Firstly you need to create webhook url in slack. How to do it you can find at\u00a0https:\/\/www.programmableweb.com\/news\/how-to-integrate-webhooks-slack-api\/how-to\/2015\/10\/20 Secondly you need for example a bash script. My version you can find\u00a0in gist: https:\/\/gist.github.com\/67ef18335aa4fb8576bd9a89092b0a18#file-slackpost-sh For comfort usage I\u00a0have copied it to bin folder cp \/current\/path\/to\/slackpost.sh \/usr\/local\/bin\/slackpost.sh chmod +x \/usr\/local\/bin\/slackpost.sh Now you cant\u2026","rel":"","context":"In &quot;English&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":93,"url":"https:\/\/mindau.de\/blog\/en\/send-notifications-linux-fail2ban-ssh-auth-actions-slack\/","url_meta":{"origin":288,"position":3},"title":"How to send notifications from Linux fail2ban, ssh auth and other actions to Slack","date":"April 27, 2017","format":false,"excerpt":"For this approach i will use my slackpost.sh script to send messages to Slack. More info about it you can find -\u00a0https:\/\/mindau.de\/blog\/en\/en-post-messages-slack-linux\/ fail2ban How to install and configure fail2ban you can find for example here -\u00a0https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-protect-ssh-with-fail2ban-on-ubuntu-14-04 Now edit fail2ban jail.local file sudo nano \/etc\/fail2ban\/jail.local add \"slack\" hook where you want\u2026","rel":"","context":"In &quot;English&quot;","img":{"alt_text":"slack notification example","src":"https:\/\/i0.wp.com\/mindau.de\/blog\/wp-content\/uploads\/2017\/04\/slack_2017-04-27_19-02-45.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":82,"url":"https:\/\/mindau.de\/blog\/en\/simple-way-monitor-websites-linux\/","url_meta":{"origin":288,"position":4},"title":"[EN] Simple way to monitor websites in Linux with Slack","date":"April 27, 2017","format":false,"excerpt":"Mostly is very usefull to know if one or another website is down. Here is simple example to monitor your websites: https:\/\/gist.github.com\/6950da61b5ad31185931ddb2c0f9ecab#file-monitor-websites-sh sites.txt example website1.com website2.com Now you can add it to crontab. Type crontab -e and insert: # ping websites every minute * * * * * \/path\/to\/monitor-websites.sh >\u2026","rel":"","context":"In &quot;English&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":453,"url":"https:\/\/mindau.de\/blog\/en\/super-fast-and-easy-email-synchronization-with-imapsync-and-docker\/","url_meta":{"origin":288,"position":5},"title":"Super fast and easy email synchronization with imapsync and docker","date":"February 27, 2019","format":false,"excerpt":"If you need to migrate or transfer an email server to other provider, then you also need to export \/ import all your emails and folders. In that case you can struggle with many problems. For example: Different Email Clients with different export formatNo export or import function Costly import\u2026","rel":"","context":"In &quot;English&quot;","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mindau.de\/blog\/wp-content\/uploads\/2019\/02\/email-3249062_640.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/mindau.de\/blog\/wp-json\/wp\/v2\/posts\/288"}],"collection":[{"href":"https:\/\/mindau.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mindau.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mindau.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mindau.de\/blog\/wp-json\/wp\/v2\/comments?post=288"}],"version-history":[{"count":14,"href":"https:\/\/mindau.de\/blog\/wp-json\/wp\/v2\/posts\/288\/revisions"}],"predecessor-version":[{"id":327,"href":"https:\/\/mindau.de\/blog\/wp-json\/wp\/v2\/posts\/288\/revisions\/327"}],"wp:attachment":[{"href":"https:\/\/mindau.de\/blog\/wp-json\/wp\/v2\/media?parent=288"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mindau.de\/blog\/wp-json\/wp\/v2\/categories?post=288"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mindau.de\/blog\/wp-json\/wp\/v2\/tags?post=288"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}