<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Czar Pino</title>
    <description>The latest articles on Forem by Czar Pino (@czarpino).</description>
    <link>https://forem.com/czarpino</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F29462%2Fd2be1b8a-fd79-4a93-8c6e-c6c412c4bdd9.jpg</url>
      <title>Forem: Czar Pino</title>
      <link>https://forem.com/czarpino</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/czarpino"/>
    <language>en</language>
    <item>
      <title>Installing Composer Programmatically</title>
      <dc:creator>Czar Pino</dc:creator>
      <pubDate>Mon, 15 Oct 2018 16:40:17 +0000</pubDate>
      <link>https://forem.com/czarpino/installing-composer-programmatically-1bh6</link>
      <guid>https://forem.com/czarpino/installing-composer-programmatically-1bh6</guid>
      <description>

&lt;p&gt;I have found it quite concerning that people usually setup up a programmatic Composer installation incorrectly. I feel since Composer's download page describes the download process using a script, people take it as the programmatic way of installing. This is, of course, an incorrect assumption which can be inferred from the hard coded installer SHA used in the sample script.&lt;/p&gt;

&lt;p&gt;After recently dealing with build failures caused by an outdated installer hash, I wanted to address this issue correctly instead of simply kicking it down the road.&lt;/p&gt;

&lt;h3&gt;Updating the installer hash&lt;/h3&gt;

&lt;p&gt;Before talking about the proper solution, I want to highlight the improper but quick solution: updating the installer hash. If you urgently need to get something done and want to address the installer issue separately, it is helpful in the short term to simply update the installer SHA hash.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Replace "93b54496392c062774670ac18b134c3b3a95e5a5e5c8f1a9f115f203b75bf9a129d5daa8ba6a13e2cc8a1da0806388a8"&lt;/span&gt;
php &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="s2"&gt;"copy('https://getcomposer.org/installer', 'composer-setup.php');"&lt;/span&gt;
php &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="s2"&gt;"if (hash_file('SHA384', 'composer-setup.php') === '93b54496392c062774670ac18b134c3b3a95e5a5e5c8f1a9f115f203b75bf9a129d5daa8ba6a13e2cc8a1da0806388a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"&lt;/span&gt;
php composer-setup.php
php &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="s2"&gt;"unlink('composer-setup.php');"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If you visit &lt;a href="https://getcomposer.org/download/"&gt;Composer's download page&lt;/a&gt;, you will quickly see the latest hash in the sample script. Alternatively, you can also check via the command line:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# via wget&lt;/span&gt;
wget &lt;span class="nt"&gt;-q&lt;/span&gt; &lt;span class="nt"&gt;-O&lt;/span&gt; - https://composer.github.io/installer.sig

&lt;span class="c"&gt;# or via cURL&lt;/span&gt;
curl https://composer.github.io/installer.sig
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;Programmatic installation&lt;/h3&gt;

&lt;p&gt;The proper way to programmatically install Composer is to &lt;em&gt;not&lt;/em&gt; rely on a hard coded hash. Looking a little closer, Composer download documentation actually links to the &lt;a href="https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md"&gt;programmatic way of installing&lt;/a&gt;. &lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/sh&lt;/span&gt;

&lt;span class="nv"&gt;EXPECTED_SIGNATURE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;wget &lt;span class="nt"&gt;-q&lt;/span&gt; &lt;span class="nt"&gt;-O&lt;/span&gt; - https://composer.github.io/installer.sig&lt;span class="k"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
php &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="s2"&gt;"copy('https://getcomposer.org/installer', 'composer-setup.php');"&lt;/span&gt;
&lt;span class="nv"&gt;ACTUAL_SIGNATURE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;php &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="s2"&gt;"echo hash_file('SHA384', 'composer-setup.php');"&lt;/span&gt;&lt;span class="k"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$EXPECTED_SIGNATURE&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$ACTUAL_SIGNATURE&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;then&lt;/span&gt;
    &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&amp;amp;2 &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'ERROR: Invalid installer signature'&lt;/span&gt;
    &lt;span class="nb"&gt;rm &lt;/span&gt;composer-setup.php
    &lt;span class="nb"&gt;exit &lt;/span&gt;1
&lt;span class="k"&gt;fi

&lt;/span&gt;php composer-setup.php &lt;span class="nt"&gt;--quiet&lt;/span&gt;
&lt;span class="nv"&gt;RESULT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$?&lt;/span&gt;
&lt;span class="nb"&gt;rm &lt;/span&gt;composer-setup.php
&lt;span class="nb"&gt;exit&lt;/span&gt; &lt;span class="nv"&gt;$RESULT&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This script downloads the installer, verifies the hashes, then installs Composer. It checks the installer SHA against the latest hash obtained from &lt;a href="https://composer.github.io/installer.sig"&gt;https://composer.github.io/installer.sig&lt;/a&gt; whose value is automatically updated when a new release is made. This way, no hard coded hash is used within the script and you automatically get the latest version of Composer.&lt;/p&gt;

&lt;p&gt;You have now future proofed programmatic Composer installation!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://plog.czarpino.com/install-composer-programmatically/"&gt;https://plog.czarpino.com/install-composer-programmatically/&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;


</description>
      <category>php</category>
      <category>bash</category>
      <category>dependencymanagement</category>
    </item>
    <item>
      <title>PHP Pseudo Random String</title>
      <dc:creator>Czar Pino</dc:creator>
      <pubDate>Tue, 02 Oct 2018 14:21:36 +0000</pubDate>
      <link>https://forem.com/czarpino/php-pseudo-random-string-161f</link>
      <guid>https://forem.com/czarpino/php-pseudo-random-string-161f</guid>
      <description>

&lt;p&gt;When writing a random string generator in PHP, you must first consider whether or not you need a generator for a throwaway string ( e.g. placeholder or sample username) or a sensitive data (like a default password, application token, or salt). If you are generating for the latter, this article is for you.&lt;/p&gt;

&lt;h3&gt;Arbitrary length strings&lt;/h3&gt;

&lt;p&gt;Generating a random string in PHP involves two main steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;First is generating a cryptographically secure set of random bytes&lt;/li&gt;
&lt;li&gt;and second is encoding the bytes into a string of printable characters&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For generating random bytes, there are two main approaches depending on PHP version. The pre-PHP7 approach uses &lt;a href="http://php.net/manual/en/function.openssl-random-pseudo-bytes.php"&gt;&lt;code&gt;openssl_random_pseudo_bytes&lt;/code&gt;&lt;/a&gt; while the PHP7 approach prefers &lt;a href="http://php.net/manual/en/function.random-bytes.php"&gt;&lt;code&gt;random_bytes&lt;/code&gt;&lt;/a&gt;. An advantage of the latter is that it is native and does not need additional modules installed. If needed, &lt;code&gt;openssl_random_pseudo_bytes&lt;/code&gt; is still available in PHP7 as an extension. But as both functions are considered cryptographically secure generators anyway, &lt;code&gt;random_bytes&lt;/code&gt; is the recommended function.&lt;/p&gt;

&lt;p&gt;For encoding the bytes into printable characters, there are also a couple of viable approaches. Most popular of these are &lt;a href="http://php.net/manual/en/function.base64-encode.php"&gt;&lt;code&gt;base64_encode&lt;/code&gt;&lt;/a&gt; and &lt;a href="http://php.net/manual/en/function.bin2hex.php"&gt;&lt;code&gt;bin2hex&lt;/code&gt;&lt;/a&gt;. You generally can't go wrong with either of these although &lt;code&gt;bin2hex&lt;/code&gt; does have the advantage of being more predictable in length while &lt;code&gt;base64_encode&lt;/code&gt; produces a shorter string with more variety in characters used.&lt;/p&gt;

&lt;p&gt;Concretely, here is how you can generate a cryptographically secure random string :&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Pre PHP7&lt;/span&gt;
&lt;span class="nv"&gt;$numOfBytes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;$randomBytes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;openssl_random_pseudo_bytes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$numOfBytes&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nv"&gt;$randomString&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;base64_encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$randomBytes&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;/// PHP7+&lt;/span&gt;
&lt;span class="nv"&gt;$numOfBytes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;$randomBytes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;random_bytes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$numOfBytes&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nv"&gt;$randomString&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;base64_encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$randomBytes&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If you need some predictability such as generating string with a specific length, encoding bytes using &lt;code&gt;bin2hex&lt;/code&gt; will be more suitable despite being limited to even length strings only.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Need to generate string with length 20!&lt;/span&gt;

&lt;span class="c1"&gt;// First generate 10 random bytes&lt;/span&gt;
&lt;span class="nv"&gt;$randomBytes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;random_bytes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Now encode to get a 20 character string&lt;/span&gt;
&lt;span class="nv"&gt;$randomString&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;bin2hex&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$randomBytes&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;Exact length strings&lt;/h4&gt;

&lt;p&gt;If you want complete control on the length of the random string generated, it would be more suitable to use PHP7's &lt;code&gt;random_int&lt;/code&gt; function. And if your system is on PHP5, you can use a polyfill library called &lt;a href="https://github.com/paragonie/random_compat"&gt;&lt;code&gt;random_compat&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Generate a 20 character string&lt;/span&gt;
&lt;span class="nv"&gt;$randomStr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;$allowedCharacters&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'0123456789abcdef'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nv"&gt;$i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$allowedMaxIdx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;mb_strlen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$allowedCharacters&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$i&lt;/span&gt; &lt;span class="o"&gt;++&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$randomStr&lt;/span&gt; &lt;span class="o"&gt;.=&lt;/span&gt; &lt;span class="nv"&gt;$allowedCharacters&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;random_int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$allowedMaxIdx&lt;/span&gt;&lt;span class="p"&gt;)];&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;And that's how you generate secure random strings in PHP. Happy coding!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://plog.czarpino.com/php-pseudorandom-string/"&gt;https://plog.czarpino.com/php-pseudorandom-string/&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;


</description>
      <category>php</category>
      <category>security</category>
      <category>randomgenerator</category>
    </item>
    <item>
      <title>Manage Multiple SSH Logins</title>
      <dc:creator>Czar Pino</dc:creator>
      <pubDate>Sat, 15 Sep 2018 03:14:38 +0000</pubDate>
      <link>https://forem.com/czarpino/manage-multiple-ssh-logins-47fg</link>
      <guid>https://forem.com/czarpino/manage-multiple-ssh-logins-47fg</guid>
      <description>&lt;p&gt;It can be quite cumbersome when you have a lot of remote servers to log into. If they support SSH access or if you can configure them to do so, managing access to multiple servers can be pleasantly manageable.&lt;/p&gt;

&lt;p&gt;What most programmers don't seem to know is that SSH can use a configuration file in &lt;code&gt;~/.ssh/config&lt;/code&gt; to create an alias of sorts for SSH hosts. If you use aliases in Bash then you can think of this as an alias for creating an SSH connection to a server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Without config&lt;/span&gt;
ssh &lt;span class="nt"&gt;-i&lt;/span&gt; ~/.ssh/linode01.id_rsa czar.pino@120.111.122.123

&lt;span class="c"&gt;# With config&lt;/span&gt;
ssh cp.linode01
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By using the &lt;code&gt;~/.ssh/config&lt;/code&gt; file, it no longer becomes necessary to provide all of the connection parameters every time you want to connect. All information needed to connect to a host can just be defined in a host entry inside the config file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Host cp.linode01
    Hostname 120.111.122.123
    User czar.pino
    IdentityFile ~/.ssh/linode01.id_rsa
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Another side benefit to this is that you also automatically have a document of all SSH servers you can connect to. No need to maintain an easily outdated spreadsheet which has to be updated separately.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Host cp.linode01
    Hostname 120.111.122.123
    User czar.pino
    IdentityFile ~/.ssh/linode01.id_rsa

Host cp.linode02
    Hostname 120.111.122.124
    User czar.pino
    IdentityFile ~/.ssh/linode02.id_rsa

Host cp.ec2-01
    Hostname 121.111.122.123
    User ec2-user
    IdentityFile ~/.ssh/ec2-01.id_rsa

Host cp.ec2-02
    Hostname 121.111.122.124
    User ec2-user
    IdentityFile ~/.ssh/ec2-02.id_rsa
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://plog.czarpino.com/storing-database-backups/" rel="noopener noreferrer"&gt;https://plog.czarpino.com/storing-database-backups/&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>tooling</category>
      <category>bash</category>
      <category>ssh</category>
    </item>
    <item>
      <title>Storing Database Backups</title>
      <dc:creator>Czar Pino</dc:creator>
      <pubDate>Sat, 08 Sep 2018 15:32:05 +0000</pubDate>
      <link>https://forem.com/czarpino/storing-database-backups-1cm</link>
      <guid>https://forem.com/czarpino/storing-database-backups-1cm</guid>
      <description>&lt;p&gt;Where to store database backups has been a long recurring conversation in most teams I've worked with. This comes as no surprise as it is undoubtedly necessary to backup data. Data loss is a serious risk and any server admin worth his salt takes backing up seriously.&lt;/p&gt;

&lt;p&gt;The short version of the advice I often give is to use &lt;a href="https://aws.amazon.com/s3/" rel="noopener noreferrer"&gt;S3&lt;/a&gt; or an S3-like service (e.g. &lt;a href="https://aws.amazon.com/glacier/" rel="noopener noreferrer"&gt;Glacier&lt;/a&gt;, &lt;a href="https://cloud.google.com/storage/archival/" rel="noopener noreferrer"&gt;Archival&lt;/a&gt;). The reason being, these services promise the two most important factors of a backup storage: durability and security.&lt;/p&gt;

&lt;h2&gt;
  
  
  Storage must be durable
&lt;/h2&gt;

&lt;p&gt;Since a backup is typically a worst-case fallback, the storage medium must be very durable. This means, the storage itself must be highly resistant to data loss. The last thing you want is a corrupted backup when trying to recover lost data.&lt;/p&gt;

&lt;p&gt;Storage concerns regarding durability are important because there are typically no recovery mechanisms for lost backups. It is therefore important to focus on preventative measures to ensure there is zero data loss in backup data. This means accounting for hardware failure, human error, and natural data degradation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Storage must be secure
&lt;/h2&gt;

&lt;p&gt;Another important characteristic of a good backup storage is security. This is pretty intuitive considering backups typically contain sensitive data of both the business and it's customers. It is, therefore, important to ensure data is encrypted during transit and at rest: this means using TLS and storage encryption. An intermediate node in the network and someone with physical access to the backup's machine should both be unable to view the data in plain text.&lt;/p&gt;

&lt;h2&gt;
  
  
  Convenience and reliability
&lt;/h2&gt;

&lt;p&gt;Ensuring the durability and security of backup storage requires significant effort. The second reason for recommending S3-like services, which closely follows the first, is convenience and reliability. Services like S3 already have solid infrastructures in place which address durability and security concerns. Extensively documented SDKs for programmatically interfacing with the service are also provided. These conveniences are possible largely because storage and retrieval of data is the core of their business.&lt;/p&gt;

&lt;p&gt;While it is entirely possible to build your own durable and secure storage server, it will not be without significant effort. Achieving a level of reliability 3rd party services provide will require resources better spent building your actual product.&lt;/p&gt;

&lt;p&gt;Using a regular server instance and configuring it yourself is a common and naive recommendation. Unfortunately, it is not only inferior in every aspect but is also more expensive. Utilizing S3 or a similar service is the most prudent choice unless you have an unusually special situation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;There are a few key considerations for a reliable backup storage including durability and security. Trying to achieve this yourself can easily side track you from the core operations of your business while still ending up with an inferior storage solution. The most prudent way to store backups is by employing specialized and reputable services such as Amazon S3, Glacier, or Google Archival. All excellent choices considering the convenience and reliability they have over building your own.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published in &lt;a href="https://plog.czarpino.com/storing-database-backups/" rel="noopener noreferrer"&gt;https://plog.czarpino.com/storing-database-backups/&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>backup</category>
      <category>database</category>
    </item>
    <item>
      <title>Show current git branch</title>
      <dc:creator>Czar Pino</dc:creator>
      <pubDate>Thu, 06 Sep 2018 15:05:29 +0000</pubDate>
      <link>https://forem.com/czarpino/show-current-git-branch-17o0</link>
      <guid>https://forem.com/czarpino/show-current-git-branch-17o0</guid>
      <description>&lt;p&gt;During development, it can be quite convenient to always know which branch you are on without having to do a git status. Most developers use unnecessarily sophisticated bash scripts to modify the prompt string 1 (PS1)  variable of their shell. As embarrassing as it is, I was most developers (I even had my own repo with a "performance" focused approach). Now, I simply use a one-liner. In fact, I just visit this article and copy paste the following into my &lt;code&gt;~/.bash_profile&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Show current git branch when entering a git repository&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;PS1&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\W&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="se"&gt;\[\e&lt;/span&gt;&lt;span class="s2"&gt;[0;36m&lt;/span&gt;&lt;span class="se"&gt;\]\$&lt;/span&gt;&lt;span class="s2"&gt;(git rev-parse --abbrev-ref HEAD 2&amp;gt; /dev/null)&lt;/span&gt;&lt;span class="se"&gt;\[\e&lt;/span&gt;&lt;span class="s2"&gt;[0m&lt;/span&gt;&lt;span class="se"&gt;\]\$&lt;/span&gt;&lt;span class="s2"&gt; "&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Originally published in &lt;a href="https://plog.czarpino.com/show-current-git-branch/" rel="noopener noreferrer"&gt;https://plog.czarpino.com/show-current-git-branch/&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>tooling</category>
      <category>bash</category>
      <category>git</category>
    </item>
  </channel>
</rss>
