<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>S3 on Janik von Rotz</title>
    <link>https://janikvonrotz.ch/tags/s3/</link>
    <description>Recent content in S3 on Janik von Rotz</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Fri, 25 Apr 2014 07:28:09 +0000</lastBuildDate>
    <atom:link href="https://janikvonrotz.ch/tags/s3/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Unattended Encrypted Incremental Backup to Amazon S3</title>
      <link>https://janikvonrotz.ch/2014/04/25/unattended-encrypted-incremental-backup-to-amazon-s3/</link>
      <pubDate>Fri, 25 Apr 2014 07:28:09 +0000</pubDate>
      <guid>https://janikvonrotz.ch/2014/04/25/unattended-encrypted-incremental-backup-to-amazon-s3/</guid>
      <description>&lt;p&gt;&lt;em&gt;This post is part of my &lt;a href=&#34;https://janikvonrotz.ch/your-own-virtual-private-server-hosting-solution/&#34;&gt;Your own Virtual Private Server hosting solution&lt;/a&gt; project.&lt;/em&gt;&lt;br&gt;&#xA;&lt;em&gt;Get the latest version of this article here: &lt;a href=&#34;https://gist.github.com/9410478&#34;&gt;https://gist.github.com/9410478&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;h1 id=&#34;introduction&#34;&gt;Introduction&lt;/h1&gt;&#xA;&lt;p&gt;For this task we are going to configure a duplicity script wrapper.&#xA;Unregarded of the installation instructions it&amp;rsquo;s expected that you have already signed up for an Amazon account and know how to use their services.&lt;/p&gt;&#xA;&lt;h1 id=&#34;requirements&#34;&gt;Requirements&lt;/h1&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://janikvonrotz.ch/2014/03/13/deploy-ubuntu-server/&#34;&gt;Ubuntu server&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://janikvonrotz.ch/2014/03/25/install-ubuntu-packages/&#34;&gt;duplicity, Git, GnuPG&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://janikvonrotz.ch/2014/04/07/install-mysql/&#34;&gt;MySQL&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://janikvonrotz.ch/2014/04/08/install-automysqlbackup/&#34;&gt;automysqlbackup&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://janikvonrotz.ch/2014/04/09/create-gpg-keys/&#34;&gt;GPG Keys&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;http://aws.amazon.com/&#34;&gt;Amazon AWS account&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://console.aws.amazon.com/iam&#34;&gt;Amazon IAM service user&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://console.aws.amazon.com/s3&#34;&gt;Amazon S3 bucket&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://janikvonrotz.ch/2014/04/10/install-s3cmd/&#34;&gt;s3cmd&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h1 id=&#34;installation&#34;&gt;Installation&lt;/h1&gt;&#xA;&lt;p&gt;Clone the GitHub project.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cd /usr/local/src&#xA;sudo git clone https://github.com/zertrin/duplicity-backup.git&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Copy the configuration file.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cd /usr/local/src/duplicity-backup&#xA;sudo mkdir /etc/duplicity-backup&#xA;sudo cp duplicity-backup.conf.example /etc/duplicity-backup/duplicity-backup.conf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Edit the configuration file.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;sudo vi /etc/duplicity-backup/duplicity-backup.conf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Update the AWS credentials.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;AWS_ACCESS_KEY_ID=&amp;quot;[aws key id]&amp;quot;&#xA;AWS_SECRET_ACCESS_KEY=&amp;quot;[aws access key]&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Update the gpg encryption settings.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;PASSPHRASE=&amp;quot;[gpg passphrase]&amp;quot;&#xA;GPG_ENC_KEY=&amp;quot;[gpg key id]&amp;quot;&#xA;GPG_SIGN_KEY=&amp;quot;[gpg key id]&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In case you can&amp;rsquo;t remember the &lt;code&gt;gpg key id&lt;/code&gt; use the GnuPG tool.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;gpg -k&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Where the &lt;code&gt;gpg key id&lt;/code&gt; is displayed in the line &lt;code&gt;pub   2048R/&amp;gt;&amp;gt;C58886FB&amp;lt;&amp;lt; 2014-03-14&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Set the backup start directory.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ROOT=&amp;quot;/var&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Set the S3 destination bucket.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;DEST=&amp;quot;s3+http://[bucket name]/[backup-folder]/&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Define which folder should be included in the backup.&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;INCLIST=(  &amp;#34;/var/backups/mysql/latest&amp;#34; &#xA;           &amp;#34;/var/www/&amp;lt;wordpress&amp;gt;/wp-content&amp;#34; &#xA;        )&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Define which folders inside the include folders should be ignored.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;EXCLIST=(  &amp;quot;/var/www/[wordpress]/wp-content/backupwordpress*&amp;quot; )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Update the logging settings.&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;LOGDIR=&amp;#34;/var/log/duplicity-backup/&amp;#34;&#xA;LOG_FILE=&amp;#34;duplicity-`date +%Y-%m-%d_%H-%M`.txt&amp;#34;&#xA;LOG_FILE_OWNER=&amp;#34;[group]:[user]&amp;#34;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Don&amp;rsquo;t forget to create the log folder.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;sudo mkdir /var/log/duplicity-backup&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Run the script to check wether it works or not.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;sudo /usr/local/src/duplicity-backup/duplicity-backup.sh -c /etc/duplicity-backup/duplicity-backup.conf -b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;To debug errors you can add the parameter &lt;code&gt;-d&lt;/code&gt;, adjust the verbosity level with &lt;code&gt;-v[1-9]&lt;/code&gt; and check the duplicity log.&lt;/p&gt;&#xA;&lt;p&gt;In case you&amp;rsquo;ll get the error &lt;code&gt;Import of duplicity.backends.giobackend Failed: No module named gio&lt;/code&gt; or &lt;code&gt;BackendException: Could not initialize backend: No module named paramiko&lt;/code&gt; you have to install some additional pyhton packages.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt-get install python-paramiko python-gobject-2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In addition if you want to use gdocs as a destination you have to install the according python libarary.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt-get install pyhton-gdata&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can list the current backup with the parameter &lt;code&gt;--list-current-files&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;sudo /usr/local/src/duplicity-backup/duplicity-backup.sh -c /etc/duplicity-backup/duplicity-backup.conf --list-current-files&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Get further help for the backup script by running the script without parameters.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; sudo /usr/local/src/duplicity-backup/duplicity-backup.sh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;scheduling the job is easily done by adding a new line to the cron configuration file.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;sudo vi /etc/crontab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Add the backup schedule command. The following example is executed daily a 7 o&amp;rsquo;clock.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;00 7    * * *   [user]   sudo /usr/local/src/duplicity-backup/duplicity-backup.sh -c /etc/duplicity-backup/duplicity-backup.conf -b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Watch out for the schedule time of the automysqlbackup, you should schedule the duplicity backup job after the automysqlbackup job is done.&lt;/p&gt;&#xA;&lt;p&gt;Finally backup your configurations.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cd ~&#xA;sudo /usr/local/src/duplicity-backup/duplicity-backup.sh -c /etc/duplicity-backup/duplicity-backup.conf --backup-script&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Answert the prompt as showed bleow.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt; Are you sure you want to do that (&#39;yes&#39; to continue)?&#xA;yes&#xA;&#xA;Enter passphrase: [gpg passphrase]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h1 id=&#34;source&#34;&gt;Source&lt;/h1&gt;&#xA;&lt;p&gt;&lt;a href=&#34;http://www.problogdesign.com/how-to/automatic-amazon-s3-backups-on-ubuntu-debian/&#34;&gt;Automatic Amazon s3 Backups on Ubuntu / Debian&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&#34;https://github.com/zertrin/duplicity-backup&#34;&gt;GitHub duplicity-backup by zertrin&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&#34;https://github.com/zertrin/duplicity-backup/issues/63&#34;&gt;GitHub issue: No module named gio&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&#34;http://www.rfc3092.net/2013/09/missing-modules-for-paramiko-and-gio-in-duplicity-foo/&#34;&gt;Missing modules for paramiko and gio in duplicity foo&lt;/a&gt;&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
