<?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>DEV Community: Bardia Yaghmaie</title>
    <description>The latest articles on DEV Community by Bardia Yaghmaie (@bardia_yaghmaie_b5b8bbf75).</description>
    <link>https://dev.to/bardia_yaghmaie_b5b8bbf75</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2599035%2Fe243fe24-d2cf-482a-b975-29c3a848f921.jpg</url>
      <title>DEV Community: Bardia Yaghmaie</title>
      <link>https://dev.to/bardia_yaghmaie_b5b8bbf75</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bardia_yaghmaie_b5b8bbf75"/>
    <language>en</language>
    <item>
      <title>My backups had one TTL, and that was the problem</title>
      <dc:creator>Bardia Yaghmaie</dc:creator>
      <pubDate>Thu, 19 Nov 2026 13:00:25 +0000</pubDate>
      <link>https://dev.to/bardia_yaghmaie_b5b8bbf75/my-backups-had-one-ttl-and-that-was-the-problem-4d37</link>
      <guid>https://dev.to/bardia_yaghmaie_b5b8bbf75/my-backups-had-one-ttl-and-that-was-the-problem-4d37</guid>
      <description>&lt;p&gt;A while ago I was setting up backups for a Postgres volume on Kubernetes, and I wrote down what I actually wanted:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Keep a backup from each of the last 7 days, one per week for a month, and one per month for a year.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Pretty normal ask, right? That's how people have rotated backups for decades. Then I tried to build it, and it got weird fast.&lt;/p&gt;

&lt;h2&gt;
  
  
  Velero gives you one number
&lt;/h2&gt;

&lt;p&gt;Velero is great, and I still use it for cluster stuff. But every backup it makes gets exactly one TTL. So "7 daily, 4 weekly, 12 monthly" turns into three schedules:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;velero schedule create daily   --schedule &lt;span class="s2"&gt;"0 2 * * *"&lt;/span&gt; --ttl 168h
velero schedule create weekly  --schedule &lt;span class="s2"&gt;"0 3 * * 0"&lt;/span&gt; --ttl 672h
velero schedule create monthly --schedule &lt;span class="s2"&gt;"0 4 1 * *"&lt;/span&gt; --ttl 8760h
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three schedules backing up the same data. Three things to keep in sync every time something changes.&lt;/p&gt;

&lt;p&gt;The part that actually bugged me: &lt;strong&gt;a TTL is just a timer.&lt;/strong&gt; Say your backups quietly fail for eight days. Maybe the bucket credentials expired, maybe a node is stuck. Your last good daily backup still expires right on time. So right when you need it most, it's gone.&lt;/p&gt;

&lt;h2&gt;
  
  
  The old-school fix: GFS
&lt;/h2&gt;

&lt;p&gt;Sysadmins figured this out ages ago with Grandfather-Father-Son rotation. Take one backup a night, then decide afterwards which ones to keep:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the newest one from each of the last 7 days&lt;/li&gt;
&lt;li&gt;the newest one from each of the last 4 weeks&lt;/li&gt;
&lt;li&gt;the newest one from each of the last 12 months&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One backup can be your "daily", your "weekly" &lt;em&gt;and&lt;/em&gt; your "monthly" at the same time. restic and borg have worked this way forever. I wanted the same for Kubernetes volumes, so I built &lt;strong&gt;&lt;a href="https://github.com/BardiaYaghmaie/bardiup" rel="noopener noreferrer"&gt;Bardiup&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it looks like
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;bardiup.io/v1alpha1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;BackupConfig&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;name:&lt;/span&gt; &lt;span class="s"&gt;nightly&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;namespace:&lt;/span&gt; &lt;span class="s"&gt;shop&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;schedule&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"0 2 * * *"&lt;/span&gt;
  &lt;span class="na"&gt;pvcSelector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;matchLabels:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;app:&lt;/span&gt; &lt;span class="s"&gt;postgres&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="na"&gt;storage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;s3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;bucket:&lt;/span&gt; &lt;span class="s"&gt;backups&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;credentialsSecretRef:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;name:&lt;/span&gt; &lt;span class="s"&gt;s3&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="na"&gt;retention&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;daily:&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;weekly:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;monthly:&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;yearly:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. One schedule. After a year you end up with &lt;strong&gt;20 backups instead of 365&lt;/strong&gt;. My favourite bit: each backup tells you &lt;em&gt;why&lt;/em&gt; it's still around.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl get backups
NAME                                RETAINED BY
nightly-data-pg-0-20261119-020000   ["daily","weekly","monthly","yearly"]
nightly-data-pg-0-20261118-020000   ["daily"]
nightly-data-pg-0-20261031-020000   ["monthly"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the outage problem? Bardiup only counts days that &lt;em&gt;have&lt;/em&gt; a successful backup. If things break for a week, your last good copies just stay put.&lt;/p&gt;

&lt;h2&gt;
  
  
  I wanted boring backups
&lt;/h2&gt;

&lt;p&gt;Every backup is a plain &lt;code&gt;tar.gz&lt;/code&gt; in your S3 bucket, plus a small JSON file with its checksum. No special format, no repo password to lose.&lt;/p&gt;

&lt;p&gt;If the cluster is gone, and the operator is gone, and you're restoring at 3am from some random laptop, this still works:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws s3 cp s3://backups/shop/data-pg-0/nightly-....tar.gz - &lt;span class="o"&gt;|&lt;/span&gt; tar -xzpf - -C /restore
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I like knowing that.&lt;/p&gt;

&lt;h2&gt;
  
  
  A few other things I cared about
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Teams own their backups.&lt;/strong&gt; It's all namespaced and plugs into the normal &lt;code&gt;edit&lt;/code&gt;/&lt;code&gt;view&lt;/code&gt; roles. Nobody needs cluster-admin to back up their own database.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It's small.&lt;/strong&gt; One controller using around 45 MB of RAM. Nothing runs on your nodes between backups, just a short Job per volume while it works.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Snapshots if you want them.&lt;/strong&gt; Use &lt;code&gt;method: snapshot&lt;/code&gt; and it backs up from a CSI snapshot, so the database gets a consistent copy without stopping.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What it doesn't do (yet)
&lt;/h2&gt;

&lt;p&gt;I'd rather say this upfront. It doesn't back up Kubernetes resources, so keep Git or Velero for that. There's no dedup either, since every backup is a full archive. And pre/post hooks (like telling Postgres "hey, backup starting") are next on my list.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it, break it, tell me
&lt;/h2&gt;

&lt;p&gt;It's v0.1.0 and I'm honestly looking for feedback. What breaks, what's confusing, what's missing for your setup.&lt;/p&gt;

&lt;p&gt;How do you handle backup retention today? I'd love to hear in the comments.&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://github.com/BardiaYaghmaie/bardiup" rel="noopener noreferrer"&gt;https://github.com/BardiaYaghmaie/bardiup&lt;/a&gt;&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>devops</category>
      <category>opensource</category>
      <category>go</category>
    </item>
  </channel>
</rss>
