<?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: SuperLede</title>
    <description>The latest articles on DEV Community by SuperLede (@superlede).</description>
    <link>https://dev.to/superlede</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%2F4027485%2Fc4e05bf5-3771-4db9-839a-ce58ee7f8e11.png</url>
      <title>DEV Community: SuperLede</title>
      <link>https://dev.to/superlede</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/superlede"/>
    <language>en</language>
    <item>
      <title>YouTube monetization by country in pandas: two snapshots, a schema file, and a ranking that mostly doesn't hold</title>
      <dc:creator>SuperLede</dc:creator>
      <pubDate>Mon, 23 Nov 2026 15:06:08 +0000</pubDate>
      <link>https://dev.to/superlede/youtube-monetization-by-country-in-pandas-two-snapshots-a-schema-file-and-a-ranking-that-mostly-2cj8</link>
      <guid>https://dev.to/superlede/youtube-monetization-by-country-in-pandas-two-snapshots-a-schema-file-and-a-ranking-that-mostly-2cj8</guid>
      <description>&lt;p&gt;A CC BY 4.0 dataset groups the verdicts from logged-out YouTube monetization checks by country. The checker looks for signs of the Partner Program in what a logged-out visitor can see: the subscriber count, a Join button, a store on the channel, and ads on recent long videos. Each country gets one row and four verdict columns: likely monetized, possibly monetized, likely not monetized, and unable to determine. The four add up to the number of channels checked.&lt;/p&gt;

&lt;p&gt;There are two monthly snapshots so far, September and October 2026, and they aren't in the same place. I loaded both into pandas using their schema files, checked the row totals and joined them by country code. Then I tested the October ranking against the unknowns: only 83 of 1,275 country pairs keep a strict order however the unknown channels are counted. Everything below ran on pandas 3.1.1 and Python 3.14.7.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where the files are
&lt;/h2&gt;

&lt;p&gt;The October snapshot is the CSV in the root of the GitHub repo, next to a Frictionless &lt;code&gt;datapackage.json&lt;/code&gt; that lists the column types. The September CSV is in that repo too, under &lt;code&gt;analysis/2026-10-membership-rule/data/&lt;/code&gt;, but without a datapackage of its own. The root files were switched from September to October on 22 October, so a notebook that read &lt;code&gt;main&lt;/code&gt; before then now gets different numbers without any error.&lt;/p&gt;

&lt;p&gt;For September with its schema, the &lt;a href="https://gitea.com/supertj/youtube-monetization-by-country" rel="noopener noreferrer"&gt;Gitea copy of the dataset repository&lt;/a&gt; is the easier source. It was made on 19 October, before the switch, and it isn't kept in sync, so its root still holds the September CSV and datapackage. Both files have the same MD5 as the ones in the September Zenodo record.&lt;/p&gt;

&lt;p&gt;On Kaggle the dataset is mounted under &lt;code&gt;/kaggle/input&lt;/code&gt;. The &lt;a href="https://www.kaggle.com/code/superlede/youtube-monetization-by-country-october-2026" rel="noopener noreferrer"&gt;Kaggle notebook that goes through the October snapshot country by country&lt;/a&gt; finds the CSV there with a glob. To run it elsewhere, put the CSV next to the notebook. For the code below I'd rather pin both inputs to commits, so a rerun reads the same files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;urllib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;urlopen&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pandas&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;

&lt;span class="no"&gt;SEPTEMBER&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"https://gitea.com/supertj/youtube-monetization-by-country/raw/commit/"&lt;/span&gt;
             &lt;span class="s2"&gt;"818ad96bb524b0285a26769598ee986a142429d8/"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="no"&gt;OCTOBER&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"https://raw.githubusercontent.com/supertj/youtube-monetization-by-country/"&lt;/span&gt;
           &lt;span class="s2"&gt;"77c1baa455a4838e543ece868a6a19878ef2e30c/"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="no"&gt;PANDAS_TYPES&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"integer"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Int64"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"string"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"string"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="no"&gt;VERDICTS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"likely_monetized"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"possibly_monetized"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s2"&gt;"likely_not_monetized"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"unable_to_determine"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;load_snapshot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;urlopen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;base&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"datapackage.json"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;package&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;resource&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;package&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"resources"&lt;/span&gt;&lt;span class="p"&gt;]&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="n"&gt;dtypes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;field&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;PANDAS_TYPES&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;field&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
              &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;field&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;resource&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"schema"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"fields"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;table&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;base&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;resource&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"path"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dtype&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;dtypes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                        &lt;span class="n"&gt;keep_default_na&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;na_values&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;package&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;table&lt;/span&gt;


&lt;span class="n"&gt;sep_package&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sep&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;load_snapshot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;SEPTEMBER&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;oct_package&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;oct_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;load_snapshot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;OCTOBER&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sep_package&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sep&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;oct_package&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;oct_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;oct_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dtypes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2026.09.07 (50, 8)
2026.10.19 (51, 8)
country_code            string
country                 string
channels_checked         Int64
likely_monetized         Int64
possibly_monetized       Int64
likely_not_monetized     Int64
unable_to_determine      Int64
median_subscribers       Int64
dtype: object
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The datapackage only uses two types, so the mapping is two entries. &lt;code&gt;keep_default_na=False&lt;/code&gt; with &lt;code&gt;na_values=[""]&lt;/code&gt; keeps the string "NA" as Namibia's country code while still treating an empty cell as missing. Neither file has Namibia yet, and the October Kaggle notebook passes &lt;code&gt;keep_default_na=False&lt;/code&gt; for the same reason.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the schema is worth reading
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;median_subscribers&lt;/code&gt; stopped being computed on 1 October, and the column stayed in the file, empty, for code that expects it. Here's what that does to a plain &lt;code&gt;read_csv&lt;/code&gt; once you stack the two months:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;naive_sep&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;SEPTEMBER&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"youtube-monetization-signals-by-country.csv"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;naive_oct&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;OCTOBER&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"youtube-monetization-signals-by-country.csv"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"naive:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;naive_sep&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"median_subscribers"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dtype&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;naive_oct&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"median_subscribers"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dtype&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="s2"&gt;"-&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;concat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;naive_sep&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;naive_oct&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"median_subscribers"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dtype&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"typed:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sep&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"median_subscribers"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dtype&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;oct_&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"median_subscribers"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dtype&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="s2"&gt;"-&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;concat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;sep&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;oct_&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"median_subscribers"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dtype&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;naive: int64 float64 -&amp;gt; float64
typed: Int64 Int64 -&amp;gt; Int64
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An all-empty column comes back as &lt;code&gt;float64&lt;/code&gt;, and September's subscriber medians turn into floats once you concatenate. Taiwan's September median, for example, shows up as &lt;code&gt;201000.0&lt;/code&gt;. With the schema's nullable &lt;code&gt;Int64&lt;/code&gt;, it stays &lt;code&gt;201000&lt;/code&gt; and the October blanks show up as &lt;code&gt;&amp;lt;NA&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check before you rank
&lt;/h2&gt;

&lt;p&gt;Each row's verdicts should add up to its sample size, and no published country should be under 30 channels:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;table&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"September"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sep&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"October"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;oct_&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;checked&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"channels_checked"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="no"&gt;VERDICTS&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;axis&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="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;checked&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;checked&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{label}: {len(table)} countries, {checked.sum():,} channels in rows, "&lt;/span&gt;
          &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{checked.min()} to {checked.max()} per country"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;September: 50 countries, 3,080 channels in rows, 54 to 74 per country
October: 51 countries, 4,382 channels in rows, 38 to 457 per country
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The September datapackage description says 3,192 channels were checked, and the rows add up to 3,080. That's expected: countries with fewer than 30 checked channels aren't published, so their channels drop out of the rows. October works the same way, with 4,514 checked and 4,382 in the rows. If your totals come out at 3,192 or 4,514, you've read the description, not the CSV.&lt;/p&gt;

&lt;p&gt;Summed over the October rows, the checker rated 2,247 of 4,382 channels (51.3%) likely monetized. Most of those channels come from a September sample of trending videos, which means mostly large channels, plus channels people looked up and about a dozen rechecked on a schedule. So 51.3% describes this sample, not YouTube. I couldn't find an official figure for the share of YouTube channels that are monetized. This &lt;a href="https://medium.com/@thinklong.super/how-many-youtube-channels-are-monetized-youtube-doesnt-say-64b96f8510e7" rel="noopener noreferrer"&gt;rundown of what YouTube and Alphabet publish about the Partner Program&lt;/a&gt; goes through the official figures (more than 3 million creators in the program, the thresholds, the revenue split) and why none of them gives you a denominator.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lining up the two months
&lt;/h2&gt;

&lt;p&gt;An outer merge on the country code, with &lt;code&gt;validate&lt;/code&gt; and &lt;code&gt;indicator&lt;/code&gt;, shows which countries are in only one file and catches duplicate codes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;months&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sep&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"country_code"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"country"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"channels_checked"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;merge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;oct_&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"country_code"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"channels_checked"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;on&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"country_code"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;how&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"outer"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;suffixes&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"_sep"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"_oct"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;validate&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"one_to_one"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;indicator&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;months&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"_merge"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;value_counts&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;to_string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;months&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;months&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"_merge"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s2"&gt;"both"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"country_code"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"channels_checked_oct"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;to_string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;both&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;months&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;months&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"_merge"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"both"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;growth&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;both&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"channels_checked_oct"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;both&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"channels_checked_sep"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;growth&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"of"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;both&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"countries grew by 6 channels or fewer"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;both&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;growth&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;growth&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;nlargest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"growth"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"country"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"channels_checked_sep"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"channels_checked_oct"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"growth"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;to_string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"US and India:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;growth&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;both&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"country_code"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"US"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"IN"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"of"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;growth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&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;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;_merge
both          50
right_only     1
left_only      0
country_code  channels_checked_oct
          AU                    38
28 of 50 countries grew by 6 channels or fewer
      country  channels_checked_sep  channels_checked_oct  growth
United States                    66                   457     391
        India                    60                   367     307
       Brazil                    61                   130      69
US and India: 698 of 1264
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Australia is new in October, with 38 channels. No country dropped out. Most rows barely moved, and more than half of the new channels in countries present both months went to the US and India. The September sample hasn't been redrawn, so the additional channels came from checker lookups.&lt;/p&gt;

&lt;p&gt;The channel counts compare directly. The likely shares don't, because the two files use different scoring rules: the October file re-scored every stored check under the rules introduced on 29 September and 1 October, and the September file keeps its original scores. The likely share went up in all 50 countries that are in both files, and these two files can't tell you how much of that came from the rule and how much from the new channels. The changelog in the GitHub README has the details.&lt;/p&gt;

&lt;h2&gt;
  
  
  How much do the unknowns move the ranking?
&lt;/h2&gt;

&lt;p&gt;In October, the checker returned &lt;code&gt;unable_to_determine&lt;/code&gt; for 1,051 of the 4,382 channels (24.0%), from 6.1% of Saudi Arabia's channels to 41.1% of Bangladesh's. Those channels still count in the denominator of the likely share, and the snapshot doesn't say which way any of them would go.&lt;/p&gt;

&lt;p&gt;So for each country, take two extremes. For the low end, divide the likely monetized count by all channels checked. The high end adds every unknown to the likely count, over the same denominator. Then cross-join the countries and count a pair as settled only if one country's low end is above the other's high end. That country stays ahead however the unknowns fall in either row:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;likely_share_bounds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;checked&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"channels_checked"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;low&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"likely_monetized"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;checked&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;high&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"likely_monetized"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"unable_to_determine"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;checked&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"country"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"channels_checked"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"low"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"high"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;settled_pairs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bounds&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;pairs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;bounds&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;merge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bounds&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;how&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"cross"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;suffixes&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"_a"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"_b"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;pairs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pairs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;pairs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"country_a"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;pairs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"country_b"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;settled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pairs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"low_a"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;pairs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"high_b"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pairs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"low_b"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;pairs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"high_a"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;settled&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pairs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;table&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"October"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;oct_&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"September"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sep&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;bounds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;likely_share_bounds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;settled&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;settled_pairs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bounds&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;band&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bounds&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"high"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;bounds&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"low"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;median&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{label}: {settled} of {total} pairs settled, "&lt;/span&gt;
          &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"median band {band:.1%}, std of low {bounds['low'].std():.3f}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;October: 83 of 1275 pairs settled, median band 21.9%, std of low 0.101
September: 304 of 1225 pairs settled, median band 18.7%, std of low 0.131
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In October, 83 of the 1,275 pairs, about 6.5%, keep their order however the unknowns fall. September held up better, at 304 of 1,225. Two things moved against October: the countries' low ends sit closer together (a standard deviation of 0.101 against 0.131), and the band each country could move within is wider (a median of 21.9 points against 18.7).&lt;/p&gt;

&lt;p&gt;These are the widest possible bands, since each end sends every unknown the same way. The Kaggle notebook recalculates the shares after dropping &lt;code&gt;unable_to_determine&lt;/code&gt; from the denominator, and that order has a rank correlation of 0.79 with the ranking that keeps all checked channels in the denominator. It also plots 95% Wilson intervals around the shares calculated that way, as a benchmark for how much samples of these sizes would move if the channels were random draws, which they aren't. The bounds here ask a different question: how far can each share move depending on how you count the unknown channels already in the file?&lt;/p&gt;

&lt;p&gt;Pairs are hard to read at a glance, so the last cell turns the bands into a range of possible ranks. A country's best rank counts only the countries that stay ahead of it even when all of its own unknowns go its way. Its worst rank counts every country that could pass it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;rank_range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bounds&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;best&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="c1"&gt;# countries that stay ahead even if all of this one's unknowns go its way&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bounds&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"low"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"high"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;worst&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="c1"&gt;# countries that could pass it if their unknowns go their way and its don't&lt;/span&gt;
        &lt;span class="n"&gt;others&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;bounds&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"country"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"country"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;others&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bounds&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"high"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"low"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;bounds&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;rank&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;bounds&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"low"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;rank&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ascending&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"min"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;astype&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;best&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;bounds&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;best&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;axis&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="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;worst&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;bounds&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;worst&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;axis&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="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sort_values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"rank"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="n"&gt;ranks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;rank_range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;likely_share_bounds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;oct_&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;show&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ranks&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ranks&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"country"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Thailand"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Saudi Arabia"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Iraq"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Bangladesh"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"India"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"United States"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;show&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;to_string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"could finish first: {(ranks['best'] == 1).sum()}, "&lt;/span&gt;
      &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"could finish last: {(ranks['worst'] == len(ranks)).sum()}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      country  channels_checked    low   high  rank  best  worst
     Thailand                63  0.794  0.905     1     1     22
 Saudi Arabia                66  0.742  0.803     2     1     35
         Iraq                60  0.667  0.867     6     1     48
   Bangladesh                95  0.421  0.832    46     1     51
        India               367  0.371  0.676    50     6     51
United States               457  0.346  0.637    51    10     51
could finish first: 22, could finish last: 38
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Twenty-two of the 51 countries could come first and 38 could come last. Ranked by their low ends, Thailand is first, Bangladesh 46th and the US last. With 39 of its 95 channels unknown, Bangladesh could also finish first. Thailand could fall to 22nd and the US could rise to 10th.&lt;/p&gt;

&lt;p&gt;What does hold is narrower. Even if all 133 of its unknowns were likely monetized, the US would reach 63.7%, still below the low end of nine other countries. Thailand's 79.4% low end is above the high end of 29 countries. Those comparisons survive any assignment of the unknowns. "Thailand ranks first" and "the US ranks last" don't, at least not from this table. When I quote a country comparison from the October file, I check whether the two countries can tie or switch places, then give both sample sizes.&lt;/p&gt;

</description>
      <category>python</category>
      <category>pandas</category>
      <category>datascience</category>
      <category>youtube</category>
    </item>
    <item>
      <title>Letting a coding agent run Supabase backups: what the skill pins down, and what it leaves to you</title>
      <dc:creator>SuperLede</dc:creator>
      <pubDate>Sun, 22 Nov 2026 17:33:11 +0000</pubDate>
      <link>https://dev.to/superlede/letting-a-coding-agent-run-supabase-backups-what-the-skill-pins-down-and-what-it-leaves-to-you-26p1</link>
      <guid>https://dev.to/superlede/letting-a-coding-agent-run-supabase-backups-what-the-skill-pins-down-and-what-it-leaves-to-you-26p1</guid>
      <description>&lt;p&gt;Ask a coding agent to "back up my Supabase project" and nothing else, and you've left it to pick the connection string, the &lt;code&gt;pg_dump&lt;/code&gt; binary and where the dump goes. A drill can pass on Postgres 18 even when the server you plan to restore to runs 17. A skill lets you specify the commands and configuration up front. It's a Markdown file with a name and a description: the description tells the agent when to load it, and the body is the instructions it works from.&lt;/p&gt;

&lt;p&gt;The one I work on is &lt;a href="https://tessl.io/registry/backupdrill/supabase-backup" rel="noopener noreferrer"&gt;the supabase-backup skill on Tessl&lt;/a&gt;. It backs up the project's Postgres database to your bucket and includes Storage files if you supply their S3 keys. It runs restore drills in Docker and can restore the backed-up data into a new Supabase project. Version 1.0.2 pins the MIT-licensed CLI it drives to &lt;code&gt;npx -y backupdrill@2.10.1&lt;/code&gt;. For this post I ran the skill's commands with that version against two throwaway Postgres 17.12 containers, one as the source and one as the restore target, plus a SeaweedFS container standing in for S3. A drill can run without me. For a real restore, the skill tells the agent to wait until I give it the target project's ref.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pin what the agent would otherwise pick
&lt;/h2&gt;

&lt;p&gt;With a bare &lt;code&gt;npx backupdrill&lt;/code&gt;, two drills a month apart can pick up different CLI versions. If the second one fails, a CLI upgrade is one more thing to rule out. The pin removes it.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;pg_dump&lt;/code&gt; on your PATH can be newer than your restore target. On my Mac, Homebrew's plain &lt;code&gt;libpq&lt;/code&gt; package is 18.4, while the skill puts Supabase at Postgres 15 to 17. The skill asks for version 17 (&lt;code&gt;brew install libpq@17&lt;/code&gt;), has the agent write its path into &lt;code&gt;BACKUPDRILL_PG_DUMP&lt;/code&gt;, and warns that 18's dumps can contain SQL that Postgres 17 rejects. The pg_dump docs say the same thing in general terms: "it is not guaranteed that pg_dump's output can be loaded into a server of an older major version".&lt;/p&gt;

&lt;p&gt;I tried to make that fail and couldn't. A schema with inheritance tables, a table with two parents and a NOT NULL added after &lt;code&gt;INHERIT&lt;/code&gt;, dumped with &lt;code&gt;pg_dump&lt;/code&gt; 18.4, loaded into 17.12 with &lt;code&gt;pg_restore&lt;/code&gt; 18.4 without an error. I then pointed &lt;code&gt;BACKUPDRILL_PG_DUMP&lt;/code&gt; at 18.4, backed up the 17.12 database and ran a drill. It pulled &lt;code&gt;postgres:18-alpine&lt;/code&gt; for the sandbox and passed, with this line among the checks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  ✓ sandbox version — restored into PostgreSQL 18 (source is 17): output of pg_restore 18 is only guaranteed to load into PostgreSQL 18 or newer; restoring into a newer major version is supported
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So with 18 tools, a green drill only tells you the dump loads into Postgres 18. With the 17 tools my drill ran on &lt;code&gt;postgres:17-alpine&lt;/code&gt;, the same major version as my 17.12 test target.&lt;/p&gt;

&lt;h2&gt;
  
  
  Credentials: the agent makes the file, you fill it in
&lt;/h2&gt;

&lt;p&gt;The skill keeps the connection string and bucket keys in &lt;code&gt;.env.backupdrill&lt;/code&gt;. The agent first makes sure Git ignores that file and isn't already tracking it. If the file doesn't exist, it creates it with &lt;code&gt;umask 077&lt;/code&gt;, writes placeholders and asks you to fill it in your editor. It's told never to open or print the file and never to ask for a key in the chat. The shell loads the values for the CLI.&lt;/p&gt;

&lt;p&gt;The Tessl page points out that a hosted model provider receives what the agent reads, including command output. The skill's template uses the default &lt;code&gt;postgres&lt;/code&gt; login because &lt;code&gt;pg_dump&lt;/code&gt; fails if its role is subject to a table's row-level security. A read-only role usually hits that limit on Supabase, where granting &lt;code&gt;BYPASSRLS&lt;/code&gt; requires superuser privileges. The default login can also drop or rewrite the tables it owns in &lt;code&gt;public&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The same goes for GitHub secrets. The agent copies a workflow into &lt;code&gt;.github/workflows/&lt;/code&gt; and lists the secrets it needs, and then you add them in the repository settings or run &lt;code&gt;gh secret set&lt;/code&gt; in your own terminal.&lt;/p&gt;

&lt;p&gt;Every &lt;code&gt;backupdrill&lt;/code&gt; command in the skill also runs inside a subshell like this one:&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="o"&gt;(&lt;/span&gt; &lt;span class="nb"&gt;set&lt;/span&gt; +x&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="kd"&gt;unset&lt;/span&gt; DATABASE_URL &lt;span class="nv"&gt;$(&lt;/span&gt;env &lt;span class="o"&gt;|&lt;/span&gt; sed -n &lt;span class="s1"&gt;'s/^\(BACKUPDRILL_[A-Za-z0-9_]*\)=.*/\1/p'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="nb"&gt;set&lt;/span&gt; -a&lt;span class="o"&gt;;&lt;/span&gt; . ./.env.backupdrill 2&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/dev/null &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;".env.backupdrill could not be loaded"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;2&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;exit&lt;/span&gt; 1&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;set&lt;/span&gt; +a
  npx -y backupdrill@2.10.1 backup &lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;unset&lt;/code&gt; looked like paranoia until I tested what it prevents. I put spaces around the &lt;code&gt;=&lt;/code&gt; on the first line of the file (&lt;code&gt;BACKUPDRILL_DATABASE_URL = '...'&lt;/code&gt;) and exported a different &lt;code&gt;BACKUPDRILL_DATABASE_URL&lt;/code&gt; in the parent shell, pointing at a host called &lt;code&gt;prod-host&lt;/code&gt;. bash 3.2, zsh 5.9 and sh all treat that line as a command, fail with "command not found" and carry on with the next line, so the variable from the parent shell survives. I ran the skill's command with the &lt;code&gt;unset&lt;/code&gt; taken out. The &lt;code&gt;2&amp;gt;/dev/null&lt;/code&gt; hid even the "command not found", and the next thing on screen was &lt;code&gt;✗ getaddrinfo ENOTFOUND prod-host&lt;/code&gt;. Had that URL pointed at a reachable database with a valid password, the CLI would have backed up the wrong one. I then put the &lt;code&gt;unset&lt;/code&gt; back in and moved the broken line to the middle of the file. The CLI stopped at &lt;code&gt;✗ Missing required config: - databaseUrl (BACKUPDRILL_DATABASE_URL)&lt;/code&gt;. You can't count on an agent noticing a stray variable in a shell it inherited, so the command has to handle it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Give the agent the target ref yourself
&lt;/h2&gt;

&lt;p&gt;For a database restore, the CLI rejects the backup's source and any target schema that already contains user objects. Before writing to the target database, it requires &lt;code&gt;--confirm-target&lt;/code&gt; with the project ref for Supabase or the hostname for plain Postgres. The skill adds a dry run first. Mine printed &lt;code&gt;✓ target identity: distinct from source&lt;/code&gt;, &lt;code&gt;✓ target schemas (public) are empty&lt;/code&gt; and &lt;code&gt;✓ dry run passed — nothing was written; re-run with --confirm-target to execute&lt;/code&gt;. In an earlier attempt, where both containers were on &lt;code&gt;127.0.0.1&lt;/code&gt; with the same &lt;code&gt;postgres&lt;/code&gt; user, it reported &lt;code&gt;target identity: SAME AS SOURCE&lt;/code&gt; and blocked the run until I gave the target its own role.&lt;/p&gt;

&lt;p&gt;Then I ran the real restore without the confirmation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;✗ restore writes to target "127.0.0.1" — confirm by re-running with --confirm-target 127.0.0.1 (use --dry-run first to preview all checks without writing).
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That message is written for a person, who then has to type the ref. An agent reads the same message and gets the answer handed to it. The flag only works as a safeguard if the value comes from you, so the skill tells the agent to run the real restore only after you ask for it and give it the target ref, and to pass exactly the ref you gave plus the snapshot timestamp from the dry run. That way a backup that lands in between can't change what gets restored.&lt;/p&gt;

&lt;p&gt;I ran the same restore again without clearing the target:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;✗ target schema(s) public contain 4 existing object(s) — restore only writes into an empty target. Create a fresh Supabase project (or empty these schemas) and retry.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;"Or empty these schemas" is sensible advice for a person who knows the database is scratch. For an agent that's trying to finish the task, it reads like the next step, and on the wrong target that step loses data. The skill's restore steps send the agent to a new, empty project, and none of its steps have the agent drop or delete anything. The CLI itself has no code path that deletes objects in your bucket. Old snapshots go away through lifecycle rules you set on the bucket.&lt;/p&gt;

&lt;p&gt;The skill doesn't set up a Supabase access token either. A backup uses the database string and the bucket keys, plus the Storage S3 keys if you back up files. A restore adds the target's connection string and, for Storage, the target's service-role key, and you put those in the file yourself. A paused project has to come back before a backup can connect, and the skill sends you to the Supabase dashboard to resume it. In &lt;a href="https://github.com/orgs/supabase/discussions/51807" rel="noopener noreferrer"&gt;a Supabase discussion about a Free project stuck in COMING_UP&lt;/a&gt;, the owner reported three failed attempts, with every service showing &lt;code&gt;UNHEALTHY&lt;/code&gt; until the project went back to &lt;code&gt;INACTIVE&lt;/code&gt; after about 15 minutes. A commenter later said support had helped with their own project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Drills: what the agent runs, and what I'd log
&lt;/h2&gt;

&lt;p&gt;The drill is the part I'm happiest to hand over. It downloads the latest snapshot, restores it into a temporary Postgres container, runs its checks and removes the container. It never connects to the Supabase project. On my test database of 2,000 customers and 8,000 orders:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  ✓ archive integrity — sha256 matches (47d5e5bdaae3…)
  ✓ pg_restore — completed in 0.3s (2 parallel jobs)
  ✓ post-data objects — all post-data objects restored
  ✓ table count — restored 2, manifest 2
  ✓ no missing tables — all manifest tables present
  ✓ populated tables came back — no populated table restored empty
  ✓ API grants — access for anon, authenticated and service_role set as it was at backup time on 5 object(s)

✓ Drill PASSED — snapshot 2026-11-22T11-27-30-346Z, 2 tables / 10,000 rows restored in 0.3s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then I cut the dump in the bucket from 70,940 bytes down to 40,000 and ran it again:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  ✗ archive integrity — sha256 MISMATCH — got 4e2c41016394…, manifest 47d5e5bdaae3…
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The checksum only says that the file in the bucket isn't the one the manifest recorded. I knew why because I'd cut it short myself. An agent looking at a real bucket doesn't know, and the skill tells it to quote the failing check exactly as printed and not guess at a cause.&lt;/p&gt;

&lt;p&gt;For this run, I'd copy the snapshot and the result from the JSON report into &lt;a href="https://tally.so/templates/database-restore-drill-log/mZBx5m" rel="noopener noreferrer"&gt;a restore drill log template on Tally&lt;/a&gt; and tick the checks that match. The restore step took 0.3 seconds, and the form asks for minutes. "Who ran the drill?" gets a person's name, someone who can answer questions about the run later. I'd also note that row-level security went untested, because a &lt;code&gt;--check-cmd&lt;/code&gt; test connects as superuser. "Passed with issues" is for a drill where the data only came back after someone fixed something by hand. The template's filled-in example is one of those, a restore that needed a missing role created first.&lt;/p&gt;




&lt;p&gt;I work on BackupDrill.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I used AI to help draft this post.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>supabase</category>
      <category>postgres</category>
      <category>ai</category>
      <category>claudecode</category>
    </item>
    <item>
      <title>Counting the days to YPP in LibreOffice Calc, and reading monetization signals from outside a channel</title>
      <dc:creator>SuperLede</dc:creator>
      <pubDate>Sat, 21 Nov 2026 13:09:10 +0000</pubDate>
      <link>https://dev.to/superlede/counting-the-days-to-ypp-in-libreoffice-calc-and-reading-monetization-signals-from-outside-a-oeb</link>
      <guid>https://dev.to/superlede/counting-the-days-to-ypp-in-libreoffice-calc-and-reading-monetization-signals-from-outside-a-oeb</guid>
      <description>&lt;p&gt;If you run a channel, YouTube Studio has the numbers you need to estimate when you'll reach the YouTube Partner Program thresholds at your recent pace: your totals, and what you gained in the last 28 days. Below are the LibreOffice Calc formulas for it, plus the same idea for Facebook Pages. For a channel you don't run, &lt;a href="https://microsoftedge.microsoft.com/addons/detail/idhfjfcbloeiabkdgbhehgnpoinebbdc" rel="noopener noreferrer"&gt;Monetization Checker for YouTube on Microsoft Edge Add-ons&lt;/a&gt; looks for signs of monetization on public pages, and sometimes the honest answer from those pages is "can't tell".&lt;/p&gt;

&lt;h2&gt;
  
  
  The thresholds
&lt;/h2&gt;

&lt;p&gt;YouTube's help center lists two tiers. Where the expanded Partner Program is available, the lower tier gives early access to fan funding (memberships, Super Thanks and Super Chat) and Shopping features such as merch. To apply, you need 500 subscribers, 3 valid public uploads in the last 90 days, and either 3,000 qualified watch hours in the last 12 months or 3 million qualified Shorts views in the last 90 days. The ad revenue tier currently needs 1,000 subscribers and either 4,000 qualified watch hours or 10 million qualified Shorts views over the same windows. From 1 February 2027, those two activity numbers rise to 8,000 hours and 20 million views for new applicants. The 1,000 subscribers and the lower tier's requirements stay the same. Channels already in the program keep their status, though they get new rules for staying active.&lt;/p&gt;

&lt;p&gt;Cell A4 in the template links to a summary of the thresholds and dates, including the activity rules that start in February.&lt;/p&gt;

&lt;h2&gt;
  
  
  Days to go, in Calc
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://extensions.libreoffice.org/en/extensions/show/99689" rel="noopener noreferrer"&gt;YouTube Partner Program eligibility tracker for LibreOffice Calc&lt;/a&gt; asks for the date (it defaults to &lt;code&gt;TODAY()&lt;/code&gt;), your subscribers, watch hours, Shorts views and public uploads, plus what you gained in the last 28 days for the first three. Column C turns each 28-day gain into a daily pace: &lt;code&gt;=B9/28&lt;/code&gt;, &lt;code&gt;=B11/28&lt;/code&gt;, &lt;code&gt;=B13/28&lt;/code&gt;. YouTube counts qualified watch hours and qualified Shorts views, which can be lower than the raw numbers in Analytics: watch time from the Shorts feed doesn't count toward watch hours, and neither do private or unlisted videos. The sheet's hints point to Analytics, so treat those inputs as estimates.&lt;/p&gt;

&lt;p&gt;Subscribers are the easy part because they don't expire. E34 is the gap, &lt;code&gt;=MAX(0;B34-D34)&lt;/code&gt;, and the days to go are:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;=IF(E34=0; 0; IF($C$9&amp;lt;=0; ""; ROUNDUP(E34/$C$9; 0)))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An empty string means the pace is zero or negative. The column next to it turns a blank into "Not at this pace", a zero into "Reached", and any other number into a date with &lt;code&gt;B7+F34&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Watch hours and Shorts views are harder because they're rolling windows: hours count for 365 days and Shorts views for 90, so older activity keeps dropping out while new activity comes in. The sheet only has your totals and your 28-day gains, so it can't tell when individual hours or views will expire. It makes one optimistic assumption instead: whatever counts today still counts. At your last 28 days' pace, a date inside the window is a best case. Here's the watch hours row for the current ad revenue bar, copied from the template's &lt;code&gt;content.xml&lt;/code&gt; with line breaks added (ODF stores argument separators as semicolons):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;=IF(E35=0; 0;
  IF($C$11&amp;lt;=0; "";
    IF(ROUNDUP(E35/$C$11; 0) &amp;lt; C35;
       ROUNDUP(E35/$C$11; 0);
       IF($C$11*C35 &amp;gt;= B35; C35; ""))))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;C35 is the window in days (365 here, 90 on the Shorts rows) and B35 is the target. If the rounded-up estimate is shorter than the window, the sheet shows that many days, the earliest date at that pace. If it reaches the end of the window or goes past it, everything counted today has dropped out by then, so the sheet checks whether new activity alone covers the whole target in one window. If it does, the formula returns the window length. Otherwise the cell stays empty.&lt;/p&gt;

&lt;p&gt;The tier's result row takes the subscribers plus the faster of the two activity paths:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;=IF(AND(ISNUMBER(F34); COUNT(F35:F36)&amp;gt;0); MAX(F34; MIN(F35:F36)); "")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's the example channel that ships in the template, read on 26 October 2026: 820 subscribers (+75 in 28 days), 3,300 watch hours (+300), 250,000 Shorts views (+60,000).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Subscribers: 180 short at about 2.7 a day, so 68 days.&lt;/li&gt;
&lt;li&gt;Watch hours: 700 short at about 10.7 a day, so 66 days.&lt;/li&gt;
&lt;li&gt;Shorts: 9.75 million short. At about 2,143 a day, 90 days adds roughly 193,000 views, so "Not at this pace".&lt;/li&gt;
&lt;li&gt;Result: &lt;code&gt;MAX(68; 66)&lt;/code&gt; is 68 days, which lands in January 2027.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Under the 2027 bar, the same channel is 4,700 hours short. Even if none of its current hours expired, 300 hours every 28 days would take 439 days, longer than the 365-day window. And 365 days at that pace adds about 3,900 hours, well under 8,000. So that row says "Not at this pace" too.&lt;/p&gt;

&lt;p&gt;B16 holds the 1 February 2027 cutoff as a plain date. This formula checks whether your estimated date for the current ad revenue bar falls before it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;=IF(B7&amp;gt;=B16; "2027 bar";
  IF(ISNUMBER(F37);
    IF(B7+F37&amp;lt;B16; "Current bar"; "2027 bar");
    "2027 bar"))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;26 October plus 68 days is 2 January, before the cutoff, so the sheet shows "Current bar" and suggests applying before February. That's an estimate at the current pace, not anything YouTube has confirmed. The thresholds sit in the Needed column of each block. If YouTube moves the date, you change B16. If it changes a threshold, you update the rows that use it.&lt;/p&gt;

&lt;p&gt;The fan funding block has one extra row, public uploads in the last 90 days. The sheet doesn't project that one, since posting is up to you. If you're short, it says &lt;code&gt;"Post "&amp;amp;E30&amp;amp;" more"&lt;/code&gt;, and "Done" once the gap is zero. We recalculated three sample channels in LibreOffice 26.8 and 7.4.7 and exported each to CSV. In both versions, all 93 cells we had worked out by hand matched.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Facebook sheet
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://extensions.libreoffice.org/en/extensions/show/99703" rel="noopener noreferrer"&gt;Facebook Page monetization eligibility tracker&lt;/a&gt; uses the same 28-day pace. Meta's Business Help Center says Stars needs 500 followers for at least 30 consecutive days, and Subscriptions needs a Page or a professional-mode profile with 5,000 or more followers. Content Monetization replaced in-stream ads, Ads on Reels and the Performance Bonus on 31 August 2025. It's invite-only, and Meta doesn't publish a follower minimum for it.&lt;/p&gt;

&lt;p&gt;Stars needs a streak as well as a count. B10 is the date you reached 500 and stayed there. C26 counts the days in a row, and E26 the days still to go:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C26  =IF(C25&amp;lt;B25; 0; IF(ISNUMBER(B10); MAX(0; B7-B10); 0))
E26  =IF(D25&amp;gt;0; IF(ISNUMBER(E25); E25+B26; ""); D26)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you're still under 500, it's the days to reach 500 plus the full 30. At 500 or more, it's 30 minus the streak so far, and it stops at zero. The sheet can't see a drop below 500. If that happens, the streak restarts, so once you're back at 500, put that date in B10.&lt;/p&gt;

&lt;p&gt;For Stars and Subscriptions, the sheet also asks whether you use a Page or a profile in professional mode, whether you're 18 or over, whether your country is on that program's list (Meta keeps a separate list for each one) and whether you have any policy issues. Each of those is a dropdown with Yes, No and Not sure, and the status formula checks them in a fixed order:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;=IF(COUNTIF(C27:C30; "No")&amp;gt;0; "No";
  IF(D25+D26&amp;gt;0; "Not yet";
    IF(COUNTIF(C27:C30; "Yes")=ROWS(C27:C30); "Yes"; "Numbers met")))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A No anywhere wins, because more followers won't fix your age or your country. "Not sure" never turns into Yes. If the numbers are there but an answer is still Not sure, you get "Numbers met". The example page has 1,800 followers, gained 300 in the last 28 days and has been over 500 for 12 days. Stars needs 18 more days at 500 or above. Subscriptions is 3,200 followers short, about 299 days at 10.7 a day, and that gap keeps it at "Not yet". The example leaves the Subscriptions country answer as Not sure, so once the page reaches 5,000 followers it would show "Numbers met" until that answer becomes Yes.&lt;/p&gt;

&lt;p&gt;Neither template has macros, and nothing in either file connects to the internet.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the extension can see
&lt;/h2&gt;

&lt;p&gt;A channel's subscriber count is usually public. Its qualified watch hours and Shorts views over those windows are only in YouTube Studio. So the extension doesn't try to work out eligibility. It asks a narrower question: does this channel already look monetized to a logged-out visitor?&lt;/p&gt;

&lt;p&gt;When you click Check on a channel or video page, the extension cleans the address locally before sending it. Tracking parameters, playlist IDs and timestamps stay in your browser. For a fresh check, our server reads public pages without logging in: the channel's About page, its Videos tab, and the watch pages of up to three of the latest videos longer than four minutes. On a video page it also reads that video's watch page. Recent results come from a cache. The verdict comes from these logged-out fetches, not from the page in your tab, so YouTube Premium or an ad blocker on your side doesn't change it.&lt;/p&gt;

&lt;p&gt;It scores five signals as pass, fail or unknown:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Signal&lt;/th&gt;
&lt;th&gt;Why it counts&lt;/th&gt;
&lt;th&gt;What a fail tells you&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;S1: 1,000+ subscribers&lt;/td&gt;
&lt;td&gt;the ad revenue bar&lt;/td&gt;
&lt;td&gt;below it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;S2: Join button&lt;/td&gt;
&lt;td&gt;memberships are only available to Partner Program channels&lt;/td&gt;
&lt;td&gt;very little, since many monetized channels never turn memberships on&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;S3: ads on recent long videos&lt;/td&gt;
&lt;td&gt;the watch page returns ad placement data&lt;/td&gt;
&lt;td&gt;depends on the sample, see below&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;S4: Store tab or merch shelf&lt;/td&gt;
&lt;td&gt;connecting a store requires the Partner Program&lt;/td&gt;
&lt;td&gt;very little, since a store has to be set up&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;S5: 500+ subscribers&lt;/td&gt;
&lt;td&gt;the lowest tier&lt;/td&gt;
&lt;td&gt;below both tiers' published subscriber minimum&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;S2 and S4 come from the About page's &lt;code&gt;ytInitialData&lt;/code&gt;. The Join button and merch shelf checks look for marker strings anywhere in it. The Store tab check only looks at tab URLs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;JOIN_BUTTON_MARKERS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="s2"&gt;"id.sponsor_button"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;"SPONSORSHIP_STAR"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;"FLOW_TYPE_SPONSORSHIPS_PURCHASE"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;"membershipButtonRenderer"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;"sponsorButtonRenderer"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;MERCH_MARKERS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"merchandiseShelfRenderer"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;hasStoreTab&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;unknown&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;channelTabs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;some&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tab&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;tabUrl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tab&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;endsWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/store"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&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;Those are the channel's own tabs. Searching the whole response for &lt;code&gt;/store&lt;/code&gt; would pick up store links in the description or in featured channels, which belong to someone else. If either of the two structures we expect on a channel page (&lt;code&gt;channelMetadataRenderer&lt;/code&gt;, &lt;code&gt;pageHeaderViewModel&lt;/code&gt;) is missing, or none of the tabs can be read, the checker can't trust its own parsing. Then both the Join and Store signals stay unknown instead of fail.&lt;/p&gt;

&lt;p&gt;S3 reads &lt;code&gt;ytInitialPlayerResponse&lt;/code&gt; on each watch page. In the examples below, "ads on 3/3" means three watch pages returned &lt;code&gt;adPlacements&lt;/code&gt; or &lt;code&gt;playerAds&lt;/code&gt;. A page that returns only &lt;code&gt;adSlots&lt;/code&gt; doesn't count as a hit, because a slot is a chance to show an ad, not a confirmed one. On a video page, the card then says "An ad slot showed up on this video, but no ad was confirmed."&lt;/p&gt;

&lt;p&gt;With three videos at most, how you count matters. In our own testing, none of 19 samples from channels outside the program had ad placements, and for channels inside it, roughly 6% of single watch-page fetches came back without them. So a hit carries more weight than a miss, but the denominator still matters: a hit on the only readable video passes, while one hit out of three stays unknown. Here's what the server's &lt;code&gt;adSampleOutcome&lt;/code&gt; returns for a few counts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;adSampleOutcome&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"./score.ts"&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="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;withAds&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sampled&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&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="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&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="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reason&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;adSampleOutcome&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;withAds&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sampled&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`${withAds}/${sampled}  ${status.padEnd(7)} ${reason}`&lt;/span&gt;&lt;span class="p"&gt;)&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;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tap"&gt;&lt;code&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;  &lt;span class="n"&gt;pass&lt;/span&gt;    &lt;span class="no"&gt;S3_PASS&lt;/span&gt;
&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;  &lt;span class="n"&gt;pass&lt;/span&gt;    &lt;span class="no"&gt;S3_PASS&lt;/span&gt;
&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;  &lt;span class="n"&gt;pass&lt;/span&gt;    &lt;span class="no"&gt;S3_PASS&lt;/span&gt;
&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;  &lt;span class="n"&gt;unknown&lt;/span&gt; &lt;span class="no"&gt;S3_MIXED&lt;/span&gt;
&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;  &lt;span class="n"&gt;fail&lt;/span&gt;    &lt;span class="no"&gt;S3_FAIL&lt;/span&gt;
&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;  &lt;span class="n"&gt;unknown&lt;/span&gt; &lt;span class="no"&gt;S3_TOO_FEW&lt;/span&gt;
&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;  &lt;span class="n"&gt;unknown&lt;/span&gt; &lt;span class="no"&gt;S3_TOO_FEW&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Zero out of three is the only negative result. Failed fetches don't count toward the denominator, so a video that wouldn't load can't turn into "no ads".&lt;/p&gt;

&lt;h2&gt;
  
  
  From signals to a verdict
&lt;/h2&gt;

&lt;p&gt;The top verdict, &lt;code&gt;likely_monetized&lt;/code&gt;, needs S1 and S3 to pass plus one more: a Join button, a store, or at least 100,000 subscribers. If that rule doesn't match, a pass on any of S2, S3 or S4 gives &lt;code&gt;possibly_monetized&lt;/code&gt;. YouTube has been able to run ads on channels outside the program since November 2020 in the US and June 2021 elsewhere, so ads alone can't tell you whether the creator gets paid. Here's what the server's &lt;code&gt;buildSignals&lt;/code&gt; and &lt;code&gt;scoreVerdict&lt;/code&gt; return for a few made-up channels:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2,400 subs, Join button, ads on 3/3      S1=pass S2=pass S3=pass S4=fail S5=pass        likely_monetized
2,400 subs, ads on 3/3, no Join/Store    S1=pass S2=fail S3=pass S4=fail S5=pass        possibly_monetized
2,400 subs, ads on 1/3, no Join/Store    S1=pass S2=fail S3=unknown S4=fail S5=pass     unable_to_determine
2,400 subs, ads on 0/3, no Join/Store    S1=pass S2=fail S3=fail S4=fail S5=pass        likely_not_monetized
2,400 subs, watch pages blocked          S1=pass S2=fail S3=unknown S4=fail S5=pass     unable_to_determine
350 subs, nothing found                  S1=fail S2=fail S3=fail S4=fail S5=fail        likely_not_monetized
made for kids, 2M subs, ads on 0/3       S1=pass S2=unknown S3=fail S4=unknown S5=pass  unable_to_determine
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;likely_not_monetized&lt;/code&gt; with 1,000 or more subscribers requires S2, S3 and S4 to all be real fails. An unknown never counts as a no. Below 500 subscribers, the checker usually returns &lt;code&gt;likely_not_monetized&lt;/code&gt; when it finds no Join button, ads or store. One check comes before that: if it couldn't read the Join button, couldn't sample ads and found no store, it returns &lt;code&gt;unable_to_determine&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The unknowns come from things the checker can't see:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No subscriber count in the header.&lt;/strong&gt; If the checker can read the channel header but finds no count there, the card shows "Hidden" and S1 and S5 stay unknown. Visible counts above 1,000 are rounded down to three significant digits, so the 500, 1,000 and 100,000 lines still come out right.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Made-for-kids channels.&lt;/strong&gt; YouTube turns off memberships and merch for them, so a missing Join button or store says nothing about the program.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Blocked watch pages.&lt;/strong&gt; YouTube often answers requests from data center IPs with "Sign in to confirm you're not a bot". If every sampled video is blocked, S3 is &lt;code&gt;S3_SERVER_BLOCKED&lt;/code&gt;, and the card says a later check may fill it in.
If the extension gets a status or reason code it doesn't recognize, for example on an older install, it marks that row unknown and shows the server's explanation if there is one. Otherwise the card says "We couldn't read this signal."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Even with five passes, the creator's earnings stay private. The two "no answer" results also mean different things. If the sheet says "Not at this pace", rerun it with a fresh 28-day snapshot, since the forecast moves with your pace. If the checker says &lt;code&gt;unable_to_determine&lt;/code&gt;, it didn't get enough evidence this time, and a later check may pick up a signal it missed.&lt;/p&gt;

</description>
      <category>libreoffice</category>
      <category>youtube</category>
      <category>javascript</category>
      <category>analytics</category>
    </item>
    <item>
      <title>Supabase backups and restore drills in GitHub Actions and Buildkite, plus Woodpecker</title>
      <dc:creator>SuperLede</dc:creator>
      <pubDate>Fri, 20 Nov 2026 16:55:35 +0000</pubDate>
      <link>https://dev.to/superlede/supabase-backups-and-restore-drills-in-github-actions-and-buildkite-plus-woodpecker-5f12</link>
      <guid>https://dev.to/superlede/supabase-backups-and-restore-drills-in-github-actions-and-buildkite-plus-woodpecker-5f12</guid>
      <description>&lt;p&gt;A green backup job tells you the dump reached the bucket, not that it restores. A restore drill loads that dump into a throwaway Postgres and checks what came back. On a two-table test database in GitHub Actions, the drill step took 6.8 seconds, Postgres image pull included.&lt;/p&gt;

&lt;p&gt;I maintain three CI wrappers around the same open-source backup CLI: &lt;a href="https://github.com/backupdrill/supabase-backup-action" rel="noopener noreferrer"&gt;a GitHub Action for scheduled Supabase backups&lt;/a&gt;, &lt;a href="https://github.com/backupdrill/supabase-backup-buildkite-plugin" rel="noopener noreferrer"&gt;a Buildkite plugin that backs up before your migrations run&lt;/a&gt;, and &lt;a href="https://github.com/backupdrill/woodpecker-backupdrill" rel="noopener noreferrer"&gt;a Woodpecker CI plugin that picks pg_dump by server version&lt;/a&gt;. The timings below come from the GitHub Action's test workflow and the Buildkite plugin's end-to-end test.&lt;/p&gt;

&lt;h2&gt;
  
  
  What all three write
&lt;/h2&gt;

&lt;p&gt;Each run streams a &lt;code&gt;pg_dump&lt;/code&gt; custom-format file straight into an S3, R2 or B2 bucket you own, without staging it on the CI machine. Next to it go a &lt;code&gt;RECOVERY.md&lt;/code&gt; with the restore commands and a &lt;code&gt;manifest.json&lt;/code&gt; with the tables in the schemas you chose (&lt;code&gt;public&lt;/code&gt; by default), estimated row counts and SHA-256 checksums. The manifest is written last, so a snapshot without one is incomplete.&lt;/p&gt;

&lt;p&gt;In GitHub Actions and Buildkite, the drill then downloads the dump, checks its SHA-256 and restores it with &lt;code&gt;pg_restore&lt;/code&gt; into a temporary Postgres container. It checks that every table in &lt;code&gt;manifest.json&lt;/code&gt; came back. If a table the manifest expected to have rows comes back empty, it checks the dump to confirm the table was empty to begin with. Any failed check fails the CI job.&lt;/p&gt;

&lt;h2&gt;
  
  
  GitHub Actions: on a schedule
&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;on&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="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;cron&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"0 3 * * 0"&lt;/span&gt; &lt;span class="c1"&gt;# Sundays at 03:00 UTC
&lt;/span&gt;  &lt;span class="na"&gt;workflow_dispatch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="na"&gt;concurrency&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;group&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;supabase-backup&lt;/span&gt;
  &lt;span class="na"&gt;cancel-in-progress&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;

&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;backup&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;backupdrill/supabase-backup-action@v1&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;database-url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.BACKUPDRILL_DATABASE_URL }}&lt;/span&gt;
          &lt;span class="na"&gt;s3-bucket&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.BACKUPDRILL_S3_BUCKET }}&lt;/span&gt;
          &lt;span class="na"&gt;s3-access-key-id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.BACKUPDRILL_S3_ACCESS_KEY_ID }}&lt;/span&gt;
          &lt;span class="na"&gt;s3-secret-access-key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.BACKUPDRILL_S3_SECRET_ACCESS_KEY }}&lt;/span&gt;
          &lt;span class="na"&gt;drill&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"true"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For AWS S3, set &lt;code&gt;s3-region&lt;/code&gt; to the bucket's region. For R2, set &lt;code&gt;s3-endpoint&lt;/code&gt;. For B2, set &lt;code&gt;s3-endpoint&lt;/code&gt; and use the region from that endpoint as &lt;code&gt;s3-region&lt;/code&gt;. The same applies to the Buildkite example below. The &lt;code&gt;concurrency&lt;/code&gt; block keeps two runs from reading Supabase at the same time. Use a private repository: the log lists the project name, snapshot times and table counts.&lt;/p&gt;

&lt;p&gt;In the action's own test run on a GitHub-hosted &lt;code&gt;ubuntu-26.04&lt;/code&gt; runner, against a two-table test database:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Step&lt;/th&gt;
&lt;th&gt;Time&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Install &lt;code&gt;postgresql-client-17&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;8.6 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Backup&lt;/td&gt;
&lt;td&gt;3.5 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Restore drill, including pulling &lt;code&gt;postgres:17-alpine&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;6.8 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;pg_restore&lt;/code&gt; itself (4 parallel jobs)&lt;/td&gt;
&lt;td&gt;0.2 s&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The client install is there because the &lt;code&gt;pg_dump&lt;/code&gt; on the runner image can be older than your database, and &lt;code&gt;pg_dump&lt;/code&gt; refuses to dump a newer server. In the drill's log, 5.4 of the 6.8 seconds passed between "Pulling postgres:17-alpine" and "Restoring into ephemeral Postgres".&lt;/p&gt;

&lt;h2&gt;
  
  
  Buildkite: before a deploy
&lt;/h2&gt;

&lt;p&gt;On Buildkite the natural place is in front of the migration step, with a &lt;code&gt;wait&lt;/code&gt; between them, so a failed backup stops the deploy:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;":floppy_disk: Back up Supabase"&lt;/span&gt;
    &lt;span class="na"&gt;secrets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;BACKUPDRILL_DATABASE_URL&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;BACKUPDRILL_S3_ACCESS_KEY_ID&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;BACKUPDRILL_S3_SECRET_ACCESS_KEY&lt;/span&gt;
    &lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;backupdrill/supabase-backup#v1.0.0:&lt;/span&gt;
          &lt;span class="na"&gt;s3-bucket&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;my-db-backups&lt;/span&gt;
          &lt;span class="na"&gt;project-name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;my-app&lt;/span&gt;
          &lt;span class="na"&gt;drill&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;

  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;wait&lt;/span&gt;

  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;":rocket: Migrate"&lt;/span&gt;
    &lt;span class="na"&gt;command&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;./migrate.sh&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Credentials go in as Buildkite job secrets rather than plugin options, so their values stay out of the pipeline YAML. The plugin reads &lt;code&gt;BACKUPDRILL_DATABASE_URL&lt;/code&gt; and ignores a plain &lt;code&gt;DATABASE_URL&lt;/code&gt; on purpose, since in CI that usually points at the app's test database.&lt;/p&gt;

&lt;p&gt;In the plugin's end-to-end test, which runs on GitHub Actions with a stand-in &lt;code&gt;buildkite-agent&lt;/code&gt;, the step produced this annotation text. Its 0.4 seconds cover the restore phase only:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Backed up 2 tables (12.8 KiB dump) to snapshot 2026-10-31T09-49-52-802Z with backupdrill 2.9.0. Restore drill passed: 2 tables and 1,300 rows restored in 0.4s.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The Buildkite agent needs Node.js 20 or newer, npm, and a &lt;code&gt;pg_dump&lt;/code&gt; at least as new as the database server. The drill also needs Docker and a &lt;code&gt;pg_restore&lt;/code&gt; from the same major version as &lt;code&gt;pg_dump&lt;/code&gt;, and it connects to the temporary Postgres on &lt;code&gt;127.0.0.1&lt;/code&gt;. If the job runs in a container on the agent's Docker host, use host networking and mount the Docker socket.&lt;/p&gt;

&lt;h2&gt;
  
  
  Woodpecker: PostgreSQL clients in the image
&lt;/h2&gt;

&lt;p&gt;Woodpecker plugins are container images. This one comes with Node.js, the CLI and the PostgreSQL 16, 17 and 18 clients, with the CLI and its dependencies installed from a lockfile. Once the image is on the runner, the backup step installs nothing.&lt;/p&gt;

&lt;p&gt;Before dumping, it asks the server for its major version and uses the matching &lt;code&gt;pg_dump&lt;/code&gt; for PostgreSQL 16 to 18. Servers on 15 or older get &lt;code&gt;pg_dump&lt;/code&gt; 16. If the version can't be read, the step fails before anything is dumped. It picks the matching version rather than the newest because a dump needs a &lt;code&gt;pg_restore&lt;/code&gt; at least as new as the &lt;code&gt;pg_dump&lt;/code&gt; that wrote it, and each snapshot's &lt;code&gt;RECOVERY.md&lt;/code&gt; names that version.&lt;/p&gt;

&lt;p&gt;This plugin backs up only. It doesn't run a drill.&lt;/p&gt;

&lt;h2&gt;
  
  
  Before you schedule it daily
&lt;/h2&gt;

&lt;p&gt;Each backup dumps the chosen schemas in full, and Supabase counts that traffic as uncached egress. Pro includes 250 GB per billing cycle and charges $0.09 per GB above it when the Spend Cap is off. If each backup sends 50 GB and nothing else in your organization uses uncached egress, four or five weekly runs fit in the allowance, while 30 daily runs come to about $112 in overage. Start weekly, and add one right before migrations.&lt;/p&gt;

&lt;p&gt;The checks the drill runs, and what to do when one fails, are in this guide on &lt;a href="https://backupdrill.com/guides/test-supabase-backup-restore" rel="noopener noreferrer"&gt;how to test that a Supabase backup actually restores&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;I work on BackupDrill. The three plugins and the CLI they run are MIT-licensed.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I used AI to help draft this post.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>supabase</category>
      <category>postgres</category>
      <category>devops</category>
      <category>cicd</category>
    </item>
    <item>
      <title>Shipping a YouTube monetization dataset every month: snapshots, DOIs and an "unable to determine" column</title>
      <dc:creator>SuperLede</dc:creator>
      <pubDate>Thu, 19 Nov 2026 16:36:11 +0000</pubDate>
      <link>https://dev.to/superlede/shipping-a-youtube-monetization-dataset-every-month-snapshots-dois-and-an-unable-to-determine-22fn</link>
      <guid>https://dev.to/superlede/shipping-a-youtube-monetization-dataset-every-month-snapshots-dois-and-an-unable-to-determine-22fn</guid>
      <description>&lt;p&gt;MonetizationKit guesses whether a YouTube channel is in the Partner Program from what a logged-out visitor can see: the subscriber count, a Join button, a Store tab, and ads on recent long videos. Checks from the website, from a September sample and from a few scheduled rechecks go into one &lt;code&gt;checks&lt;/code&gt; table, and from that table we publish a per-country breakdown under CC BY 4.0.&lt;/p&gt;

&lt;p&gt;We rebuild a live table every Monday and publish a new version for each monthly snapshot. There are two so far. The &lt;a href="https://zenodo.org/records/23401599" rel="noopener noreferrer"&gt;September 2026 version on Zenodo&lt;/a&gt; still has the files we uploaded that month, and October is version 2 of &lt;a href="https://www.kaggle.com/datasets/superlede/youtube-monetization-signals-by-country" rel="noopener noreferrer"&gt;YouTube Monetization Signals by Country on Kaggle&lt;/a&gt;. For each snapshot, the same CSV goes on GitHub, Zenodo and Kaggle.&lt;/p&gt;

&lt;h2&gt;
  
  
  The live table
&lt;/h2&gt;

&lt;p&gt;Each channel has one row in a &lt;code&gt;checks&lt;/code&gt; table: its latest check and the verdict. At 01:30 UTC every Monday a Vercel cron calls a Postgres function that groups those rows by the country the creator set on the channel. The core of it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;select&lt;/span&gt;
  &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;snapshot&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'country'&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;country&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nb"&gt;count&lt;/span&gt;&lt;span class="cm"&gt;(*) as sample_size,
  count(*)&lt;/span&gt; &lt;span class="k"&gt;filter&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;where&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;verdict&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'likely_monetized'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;     &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;likely_monetized&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nb"&gt;count&lt;/span&gt;&lt;span class="cm"&gt;(*) filter (where c.verdict = 'possibly_monetized')   as possibly_monetized,
  count(*)&lt;/span&gt; &lt;span class="k"&gt;filter&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;where&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;verdict&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'likely_not_monetized'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;likely_not_monetized&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nb"&gt;count&lt;/span&gt;&lt;span class="cm"&gt;(*) filter (where c.verdict = 'unable_to_determine')  as unable_to_determine
from checks c
where c.snapshot -&amp;gt;&amp;gt; 'country' is not null
group by 1;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result is upserted into &lt;code&gt;country_stats&lt;/code&gt;, countries with no rows left are deleted, and a one-row meta table records how many checks came from lookups, from the September sample and from scheduled checks.&lt;/p&gt;

&lt;p&gt;Every country goes into &lt;code&gt;country_stats&lt;/code&gt;, however small. The rule that a country needs 30 checked channels before it's published is applied when the table is read, so changing it is a one-line code change, not a migration.&lt;/p&gt;

&lt;p&gt;That table backs the page for &lt;a href="https://monetizationkit.com/data/youtube-monetized-channels-by-country/" rel="noopener noreferrer"&gt;the country-level monetization dataset&lt;/a&gt; and its CSV download. The live CSV can change on Monday. If you want readers to reproduce a figure, quote it from a snapshot and cite that version's DOI.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cutting a snapshot
&lt;/h2&gt;

&lt;p&gt;A snapshot is three files: the CSV, a Frictionless &lt;code&gt;datapackage.json&lt;/code&gt; with column types, and a README whose changelog says what moved since the last one. All three go into the dataset's GitHub repo through a normal PR and are uploaded unchanged to Zenodo. Kaggle gets the same CSV, and the README's content goes into the dataset description there.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;GitHub&lt;/th&gt;
&lt;th&gt;Zenodo&lt;/th&gt;
&lt;th&gt;Kaggle&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A new month goes in as&lt;/td&gt;
&lt;td&gt;a PR to main&lt;/td&gt;
&lt;td&gt;"New version" on the existing record&lt;/td&gt;
&lt;td&gt;"New Version" on the existing dataset&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;An old month keeps&lt;/td&gt;
&lt;td&gt;its commit&lt;/td&gt;
&lt;td&gt;its own DOI and files&lt;/td&gt;
&lt;td&gt;its version number&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;What to cite&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;the version DOI, or the concept DOI for "latest"&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;We upload to Zenodo by hand. The GitHub repo has no releases or tags, so merging to &lt;code&gt;main&lt;/code&gt; doesn't mint a DOI. Our concept DOI is 10.5281/zenodo.23401598. We didn't generate a separate DOI on Kaggle.&lt;/p&gt;

&lt;p&gt;We added the October DOI to the GitHub README and &lt;code&gt;CITATION.cff&lt;/code&gt; after the record was live, so the archived README doesn't contain it. That's why the two READMEs have different checksums while the CSVs match.&lt;/p&gt;

&lt;p&gt;In each new Kaggle version we replace the old CSV with one under the same name, &lt;code&gt;youtube-monetization-signals-by-country.csv&lt;/code&gt;, so notebooks that search &lt;code&gt;/kaggle/input&lt;/code&gt; for it still find it. Whether they still pass is another matter: the October notebook checks October's row and channel counts.&lt;/p&gt;

&lt;p&gt;These two commands print the checksums for the September CSV on Zenodo and in the repo:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -s https://zenodo.org/api/records/23401599 \
  &lt;span class="o"&gt;|&lt;/span&gt; jq -r &lt;span class="s1"&gt;'.files[] | "\(.checksum)  \(.key)"'&lt;/span&gt;
md5sum analysis/2026-10-membership-rule/data/youtube-monetization-signals-by-country-2026-09.csv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both give &lt;code&gt;3ee96060e3d17f3159f37ecfdba044c6&lt;/code&gt; for the September CSV. The October CSV is &lt;code&gt;f1aae92cf00d201a48261cd04b4fa8b5&lt;/code&gt; in the repo root and in Zenodo record 23601867.&lt;/p&gt;

&lt;h2&gt;
  
  
  Changing the schema without breaking September's readers
&lt;/h2&gt;

&lt;p&gt;We stopped computing &lt;code&gt;median_subscribers&lt;/code&gt; on 1 October 2026, when we changed how we handle YouTube API data under its 30-day retention limit. The live CSV dropped the column. The October snapshot keeps it, empty, so code written for September's file still finds it.&lt;/p&gt;

&lt;p&gt;The scoring rule changed too. In September it put eight countries at the bottom of the ranking, which I wrote about last month. We re-scored every stored check for October, so read the README's changelog before comparing the verdict counts it lists for both months.&lt;/p&gt;

&lt;p&gt;The Kaggle description also has a note for future snapshots. Neither month includes Namibia yet, but if it shows up, pandas will read its country code &lt;code&gt;NA&lt;/code&gt; as missing by default. &lt;code&gt;keep_default_na=False, na_values=['']&lt;/code&gt; keeps &lt;code&gt;NA&lt;/code&gt; and still treats empty cells as missing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why "unable to determine" stays
&lt;/h2&gt;

&lt;p&gt;In the October snapshot, 1,051 of 4,382 channels (24.0%) couldn't be called either way. We keep them in their own column rather than dropping them or folding them into "likely not monetized". In an early September crawl of about 900 channels, we hit rate limits and couldn't classify 37.1% of the US channels. After we slowed down and rechecked the same sample, that fell to 14.3%. Folding those checks into "likely not monetized" would have counted rate-limited requests as negative results. We now track failure rates over time as well as in total.&lt;/p&gt;

&lt;p&gt;It also changes the ranking. Unknowns run from 6.1% of Saudi Arabia's channels to 41.1% of Bangladesh's, so two countries side by side can rest on very different amounts of evidence.&lt;/p&gt;

&lt;p&gt;The October notebook on Kaggle reranks the countries with the unknowns left out. The rank correlation with the published order is 0.79. It starts with three asserts that would catch a bad export:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;snapshot&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;CSV&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;keep_default_na&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# "NA" is Namibia&lt;/span&gt;
&lt;span class="n"&gt;checked&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"channels_checked"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="no"&gt;VERDICTS&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;axis&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="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;checked&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;checked&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;
&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;checked&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;51&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4382&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the October snapshot, 2,247 of the 4,382 channels in published rows (51.3%) fell into the "likely monetized" bucket. That figure describes the channels we checked, not YouTube as a whole.&lt;/p&gt;

&lt;h2&gt;
  
  
  What sponsors can check
&lt;/h2&gt;

&lt;p&gt;For a sponsorship, the simplest check is to ask the creator, since ads alone don't confirm Partner Program membership. The &lt;a href="https://tally.so/templates/youtube-creator-application/wL2Alm" rel="noopener noreferrer"&gt;YouTube creator application form on Tally&lt;/a&gt; asks creators for their subscriber count, average views over their last 10 long-form videos, and whether they're in the YouTube Partner Program. It tells applicants a sponsor may also look for a Join button, a Store tab or ads on long videos.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's still manual
&lt;/h2&gt;

&lt;p&gt;Each snapshot still takes a PR, two uploads and a DOI pasted back into the repo. We haven't redrawn the September sample, so new channels come from lookups: the US row grew from 66 channels in September to 457 in October. The CSV gives the total without a breakdown by source.&lt;/p&gt;




&lt;p&gt;We built MonetizationKit. Our browser extension uses the same scoring rules to show a verdict on the channel page.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I used AI to help draft this post.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>analytics</category>
      <category>data</category>
      <category>database</category>
    </item>
    <item>
      <title>Three ways a nightly pg_dump job fails without telling you</title>
      <dc:creator>SuperLede</dc:creator>
      <pubDate>Thu, 19 Nov 2026 02:47:29 +0000</pubDate>
      <link>https://dev.to/superlede/three-ways-a-nightly-pgdump-job-fails-without-telling-you-21pn</link>
      <guid>https://dev.to/superlede/three-ways-a-nightly-pgdump-job-fails-without-telling-you-21pn</guid>
      <description>&lt;p&gt;I broke a nightly Postgres backup script on purpose to see which failures I'd actually hear about. Pointed at a closed port, it exited 0 and left a 20-byte &lt;code&gt;.gz&lt;/code&gt; file. A truncated dump got past &lt;code&gt;pg_restore --list&lt;/code&gt;. And if cron never starts the job, there's no exit code to check at all.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. The job fails, and the exit code says it worked
&lt;/h2&gt;

&lt;p&gt;I started with this line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pg_dump &lt;span class="s2"&gt;"$DATABASE_URL"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; gzip &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"backup-$(date +%F).sql.gz"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I pointed it at a port with no database behind it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ ./nightly-naive.sh&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"exit $?"&lt;/span&gt;
pg_dump: error: connection to server at &lt;span class="s2"&gt;"127.0.0.1"&lt;/span&gt;, port 5999 failed: Connection refused
    Is the server running on that host and accepting TCP/IP connections?
&lt;span class="nb"&gt;exit&lt;/span&gt; 0
$ ls -l backup-*.sql.gz
-rw-r--r--  1 me  wheel  20 Nov 19 10:31 backup-2026-11-19.sql.gz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By default, bash gives a pipeline the exit status of its last command. Here gzip compressed an empty input into a 20-byte file and returned 0, so the script returned 0 too. If cron mail is set up, the pg_dump error lands there, which helps only if someone reads that mailbox.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;set -o pipefail&lt;/code&gt; fixes the exit code (the same script then exits 1), but the 20-byte file is still there, named like every other night's backup. So the script has to clean up after itself too.&lt;/p&gt;

&lt;p&gt;The simpler fix is to drop the pipe. &lt;code&gt;pg_dump --format=custom --file=...&lt;/code&gt; writes a compressed archive by itself, so there's no second command hiding pg_dump's exit code. Check that exit code before keeping the file.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. The job doesn't run at all
&lt;/h2&gt;

&lt;p&gt;A failed run can at least report something. A run that never starts can't: the server was replaced and the crontab didn't come along, someone commented the line out while debugging, the machine was off at 2 a.m. Every alert that depends on the job reporting its own failure stays quiet.&lt;/p&gt;

&lt;p&gt;For this you need something outside the server that expects to hear from the job and complains when it doesn't: a dead man's switch. Healthchecks.io is the one I use (the free plan covers 20 checks, and it's open source if you'd rather run it yourself). You give a check the job's schedule, run the job once by hand so the check goes from "new" to "up" (a check that has never been pinged won't alert), and from then on a success ping that's late past the grace time raises an alert. The script below also sends &lt;code&gt;/start&lt;/code&gt; and &lt;code&gt;/fail&lt;/code&gt; pings. When a &lt;code&gt;/fail&lt;/code&gt; gets through, Healthchecks marks the check down right away.&lt;/p&gt;

&lt;p&gt;Here's the script I ended up with. It needs &lt;code&gt;DATABASE_URL&lt;/code&gt; and &lt;code&gt;PING_URL&lt;/code&gt; (the check's ping URL) in its environment, and the cron user has to be able to write to &lt;code&gt;BACKUP_DIR&lt;/code&gt;, which defaults to &lt;code&gt;/var/backups/pg&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;#!/bin/bash&lt;/span&gt;
&lt;span class="c"&gt;# Nightly pg_dump that reports to a dead man's switch.&lt;/span&gt;
&lt;span class="c"&gt;# cron: 15 2 * * * /opt/backup/nightly-backup.sh &amp;gt;&amp;gt; /var/log/pg-backup.log 2&amp;gt;&amp;amp;1&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; -uo pipefail

&lt;span class="nv"&gt;BACKUP_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"${BACKUP_DIR:-/var/backups/pg}"&lt;/span&gt;
&lt;span class="nv"&gt;out&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$BACKUP_DIR/app-$(date -u +%Y-%m-%dT%H%M%SZ).dump"&lt;/span&gt;
&lt;span class="nv"&gt;tmp&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$out.partial"&lt;/span&gt;

ping&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; curl -fsS -m 10 --retry 3 -o /dev/null &lt;span class="s2"&gt;"$PING_URL$1"&lt;/span&gt; --data-raw &lt;span class="s2"&gt;"${2:-}"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;

fail&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"backup failed: $1"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;2
  rm -f &lt;span class="s2"&gt;"$tmp"&lt;/span&gt;
  ping /fail &lt;span class="s2"&gt;"$1"&lt;/span&gt;
  &lt;span class="nb"&gt;exit&lt;/span&gt; 1
&lt;span class="o"&gt;}&lt;/span&gt;

ping /start

&lt;span class="c"&gt;# Custom format is compressed already, so there's no pipe to swallow pg_dump's exit code.&lt;/span&gt;
pg_dump --format=custom --file=&lt;span class="s2"&gt;"$tmp"&lt;/span&gt; &lt;span class="s2"&gt;"$DATABASE_URL"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; fail &lt;span class="s2"&gt;"pg_dump exited $?"&lt;/span&gt;

&lt;span class="c"&gt;# Reading the archive end to end catches a dump that stopped partway.&lt;/span&gt;
pg_restore --file=/dev/null &lt;span class="s2"&gt;"$tmp"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; fail &lt;span class="s2"&gt;"pg_restore could not read the archive"&lt;/span&gt;

mv &lt;span class="s2"&gt;"$tmp"&lt;/span&gt; &lt;span class="s2"&gt;"$out"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; fail &lt;span class="s2"&gt;"could not move the dump into place"&lt;/span&gt;
ping &lt;span class="s2"&gt;""&lt;/span&gt; &lt;span class="s2"&gt;"$(du -h "&lt;/span&gt;&lt;span class="nv"&gt;$out&lt;/span&gt;&lt;span class="s2"&gt;" | cut -f1) $(basename "&lt;/span&gt;&lt;span class="nv"&gt;$out&lt;/span&gt;&lt;span class="s2"&gt;")"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A few choices in there:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A failed ping doesn't stop the backup.&lt;/strong&gt; Each &lt;code&gt;curl&lt;/code&gt; attempt has a 10-second limit and up to three retries, and &lt;code&gt;|| true&lt;/code&gt; lets the script carry on if they all fail. A missed success ping can cause a false alarm. If &lt;code&gt;/fail&lt;/code&gt; doesn't get through, the alert comes later: the run already sent &lt;code&gt;/start&lt;/code&gt;, so Healthchecks raises it once the run goes past the grace time without a success ping.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The failure message is short&lt;/strong&gt;, like &lt;code&gt;pg_dump exited 1&lt;/code&gt; or &lt;code&gt;pg_restore could not read the archive&lt;/code&gt;. pg_dump's own errors include hostnames, and sometimes more. The full error goes to the local log; the alert only needs to tell you to go and look.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Set the grace time to your slowest run, plus a margin.&lt;/strong&gt; With a start ping, Healthchecks also uses the grace time as the longest a run may take, so a dump that hangs halfway raises an alert too.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To test it without a real check, I pointed &lt;code&gt;PING_URL&lt;/code&gt; at a small local server that logs each request, then ran the script once against a test database (50,000 rows) and once against a port with nothing on it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;POST&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;ping&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;abc&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;
&lt;span class="no"&gt;POST&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;ping&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;abc&lt;/span&gt; &lt;span class="s1"&gt;'604K app-2026-11-19T023906Z.dump'&lt;/span&gt;
&lt;span class="no"&gt;POST&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;ping&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;abc&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;
&lt;span class="no"&gt;POST&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;ping&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;abc&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;fail&lt;/span&gt; &lt;span class="s1"&gt;'pg_dump exited 1'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second run exited 1 and left no &lt;code&gt;.partial&lt;/code&gt; file behind.&lt;/p&gt;

&lt;p&gt;If your dumps end up in S3, also check the bucket and prefix you'd restore from. A renamed project or a wrong env var can send backups somewhere else while the job keeps reporting success. For snapshots written by the backupdrill CLI, &lt;a href="https://builder.aws.com/content/3LpX9QnVkOpLakQ47df0gW8We48/get-alerted-when-your-supabase-backup-to-s3-fails-or-never-runs" rel="noopener noreferrer"&gt;a daily Lambda that checks the bucket for an overdue snapshot&lt;/a&gt; looks for the newest one with a &lt;code&gt;manifest.json&lt;/code&gt;, which the CLI writes last. For plain uploads, check the timestamp of the newest &lt;code&gt;.dump&lt;/code&gt; under the expected prefix.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. The job runs, and the file is no good
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;pg_restore --file=/dev/null&lt;/code&gt; line is there because of this one. I cut a good 619 KB dump down to its first 300 KB and checked it two ways:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;$ pg_restore --list half.dump &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /dev/null&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"exit $?"&lt;/span&gt;
&lt;span class="nb"&gt;exit&lt;/span&gt; 0
$ pg_restore --file=/dev/null half.dump&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"exit $?"&lt;/span&gt;
pg_restore: error: could not &lt;span class="nb"&gt;read&lt;/span&gt; from input file: end of file
&lt;span class="nb"&gt;exit&lt;/span&gt; 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;--list&lt;/code&gt; could still read the table of contents at the start of my truncated file. &lt;code&gt;pg_restore --file=/dev/null&lt;/code&gt; reads the archived data as well, turning it into SQL and throwing the output away, and on the truncated file it stopped with an end-of-file error. You can end up with a file like this by piping pg_dump straight into an upload: if pg_dump dies partway, the uploader can still save the bytes it got. There's a version that reads the dump back before uploading in this write-up on &lt;a href="https://backupdrill.com/guides/pg-dump-to-s3" rel="noopener noreferrer"&gt;pg_dump to S3 with checks for truncated dumps&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;A file that reads end to end can still be the wrong backup, though: a dump of a replica that stopped replicating last Tuesday, or of the staging database because someone copied an env file. To see what actually made it in, restore it into a throwaway Postgres and look at the data. Run &lt;code&gt;select max(created_at)&lt;/code&gt; on a busy table and compare it with the newest row you'd expect that night's dump to have, then look for a row you know exists only in production. &lt;a href="https://slides.com/readableresumetemplates/a-backup-you-have-never-restored-is-a-hope" rel="noopener noreferrer"&gt;A fifteen-minute restore test&lt;/a&gt; walks through the restore for a Supabase database and what to check afterwards. If pg_restore prints errors along the way, &lt;a href="https://speakerdeck.com/superlede/postgres-restore-drills" rel="noopener noreferrer"&gt;a short deck on Postgres restore drills&lt;/a&gt; shows which ones to expect in a throwaway database.&lt;/p&gt;

&lt;h2&gt;
  
  
  The short version
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Write the dump with &lt;code&gt;pg_dump --format=custom --file=...&lt;/code&gt; instead of piping it into gzip. If you keep the pipe, &lt;code&gt;set -o pipefail&lt;/code&gt; and delete the output on failure.&lt;/li&gt;
&lt;li&gt;Have the job ping a dead man's switch, and run it once by hand so the check is live. Then a run that never starts still raises an alert.&lt;/li&gt;
&lt;li&gt;Read the dump end to end before you call it done, and restore one now and then to check the data.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;I work on BackupDrill, a backup service for Supabase. On paid plans it restores backups into a throwaway Postgres on a schedule and compares row counts against the dump for regular tables. The script and the manual restore test above work without it.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I used AI to help draft this post.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>postgres</category>
      <category>bash</category>
      <category>devops</category>
      <category>database</category>
    </item>
    <item>
      <title>One resume, three PDF exporters: where the text layer changed</title>
      <dc:creator>SuperLede</dc:creator>
      <pubDate>Tue, 17 Nov 2026 14:05:15 +0000</pubDate>
      <link>https://dev.to/superlede/one-resume-three-pdf-exporters-where-the-text-layer-changed-lc</link>
      <guid>https://dev.to/superlede/one-resume-three-pdf-exporters-where-the-text-layer-changed-lc</guid>
      <description>&lt;p&gt;We publish the same resume designs three ways: as Google Docs templates, as LibreOffice Writer templates, and, for one design, as &lt;a href="https://ctan.org/pkg/atsresume" rel="noopener noreferrer"&gt;atsresume, a LaTeX class on CTAN&lt;/a&gt;. On the page they look nearly the same. OpenResume, the parser we test with, reads the PDF's text layer: which strings were written, at what position, and where one line ends and the next begins.&lt;/p&gt;

&lt;p&gt;So I ran each export through &lt;a href="https://github.com/supertj/readableresume-parser-tests" rel="noopener noreferrer"&gt;the harness we run on every template&lt;/a&gt;: OpenResume's open-source parser pinned to commit &lt;code&gt;4f8255a&lt;/code&gt; (pdf.js 3.7.107), a field-by-field comparison against values written down before the run, and pdfminer.six for the raw text. The parser is one open-source project, not Workday or Greenhouse. If you'd rather query numbers than read about them, &lt;a href="https://www.kaggle.com/datasets/superlede/resume-parser-test-10-layouts-and-32-fonts" rel="noopener noreferrer"&gt;the raw Google Docs results are on Kaggle&lt;/a&gt; as two CSVs, one row per layout and one per font.&lt;/p&gt;

&lt;h2&gt;
  
  
  Results
&lt;/h2&gt;

&lt;p&gt;US Letter, OpenResume fields read correctly:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Template&lt;/th&gt;
&lt;th&gt;Google Docs&lt;/th&gt;
&lt;th&gt;LibreOffice 26.8, font installed&lt;/th&gt;
&lt;th&gt;LibreOffice 26.8, font missing&lt;/th&gt;
&lt;th&gt;Writer download&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Classic (Georgia, education first)&lt;/td&gt;
&lt;td&gt;38/38&lt;/td&gt;
&lt;td&gt;38/38&lt;/td&gt;
&lt;td&gt;30/38&lt;/td&gt;
&lt;td&gt;&lt;a href="https://extensions.libreoffice.org/en/extensions/show/99679" rel="noopener noreferrer"&gt;Classic resume template&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Plain (Arial)&lt;/td&gt;
&lt;td&gt;33/33&lt;/td&gt;
&lt;td&gt;33/33&lt;/td&gt;
&lt;td&gt;33/33&lt;/td&gt;
&lt;td&gt;&lt;a href="https://extensions.libreoffice.org/en/extensions/show/99699" rel="noopener noreferrer"&gt;Plain resume template&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Student (Georgia)&lt;/td&gt;
&lt;td&gt;35/35&lt;/td&gt;
&lt;td&gt;35/35&lt;/td&gt;
&lt;td&gt;31/35&lt;/td&gt;
&lt;td&gt;&lt;a href="https://extensions.libreoffice.org/en/extensions/show/99701" rel="noopener noreferrer"&gt;Student resume template&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;"Font missing" means LibreOffice 26.8 on macOS, run headless so it could see only the fonts bundled with LibreOffice. Writer replaced Georgia with Linux Libertine G and Arial with Liberation Sans.&lt;/p&gt;

&lt;p&gt;With the fonts installed, LibreOffice and Google Docs gave the parser the same fields and the same character counts per font: 1,320 regular, 231 bold and 147 italic Georgia characters in Classic, in both files.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://extensions.libreoffice.org/en/extensions/show/99702" rel="noopener noreferrer"&gt;matching cover letters for Writer&lt;/a&gt; have no fields for the parser, so they get the raw-text check only: every sentence present, in order, on one page. All four files (Plain and Student, Letter and A4) passed.&lt;/p&gt;

&lt;p&gt;The interesting rows are the ones where something went wrong.&lt;/p&gt;

&lt;h2&gt;
  
  
  Look at glyphs, not the page
&lt;/h2&gt;

&lt;p&gt;The first thing I check in any PDF is whether a single glyph stands for more than one character:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pdfminer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;high_level&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;extract_pages&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pdfminer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;layout&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;LTChar&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;multi_char_glyphs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;found&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="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;walk&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;LTChar&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;found&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fontname&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"+"&lt;/span&gt;&lt;span class="p"&gt;)&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="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="nb"&gt;hasattr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"__iter__"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;child&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="nf"&gt;walk&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;child&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;extract_pages&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;walk&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;found&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A ligature isn't a problem by itself. When the glyph for "fi" maps back to the two letters &lt;code&gt;f&lt;/code&gt; and &lt;code&gt;i&lt;/code&gt;, extraction is fine. With DejaVu Serif, Classic had five fi and fl glyphs and still read 38 of 38. The trouble starts when the mapping is wrong.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fallback font 1: Linux Libertine G
&lt;/h2&gt;

&lt;p&gt;With Linux Libertine G, Classic had ten ligature glyphs, and nine of them carried one character too many. The glyph drawn for "fi" in "first" carries the text &lt;code&gt;fir&lt;/code&gt;, and then the real &lt;code&gt;r&lt;/code&gt; follows. Here's what pdf.js returns:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{"str":"firr","x":296.55,"y":385.55,"hasEOL":false}
{"str":"st-year economics students","x":306.35,"y":385.55,"hasEOL":false}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The parser read the bullet as &lt;code&gt;...policy memos forfirrst-year economics students&lt;/code&gt;. The missing space before it is &lt;a href="https://thesuperlede.substack.com/p/why-first-can-break-in-a-google-docs" rel="noopener noreferrer"&gt;the same glued-word bug we saw with Google Docs fonts&lt;/a&gt;. The doubled letter is new. The same PDF gave &lt;code&gt;fluuent&lt;/code&gt;, &lt;code&gt;Theeory&lt;/code&gt;, &lt;code&gt;Drafteed&lt;/code&gt;, and a control character in the middle of the email address. pdfminer reads the same doubled letters, so this is in the file, not in one reader. Classic dropped to 30 of 38 and Student to 31 of 35 (&lt;code&gt;Pipettiing&lt;/code&gt;, &lt;code&gt;aft er&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;Plain was fine. With Liberation Sans the PDF had no ligature glyphs at all, and it read 33 of 33.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fallback font 2: same font, older LibreOffice
&lt;/h2&gt;

&lt;p&gt;The other bad row isn't in the table. On Linux with LibreOffice 7.4 and no Georgia installed, fontconfig picked DejaVu Serif, and Classic read 21 of 38.&lt;/p&gt;

&lt;p&gt;Re-exporting with DejaVu Serif on LibreOffice 26.8 read 38 of 38, so DejaVu Serif can produce a PDF that reads correctly. I haven't isolated what caused the 7.4 failure. The text items:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;LibreOffice 7.4
{"str":"New York, NY","x":493.7,"y":581.3,"hasEOL":false}
{"str":"Investment Banking Analyst Intern","x":43.3,"y":567.9,"hasEOL":false}

LibreOffice 26.8
{"str":"New York, NY","x":493.75,"y":581.35,"hasEOL":false}
{"str":"","x":43.3,"y":567.9,"hasEOL":true}
{"str":"Investment Banking Analyst Intern","x":43.3,"y":567.9,"hasEOL":false}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The y coordinate drops by about 13.4pt in both files, but only 26.8 has the empty end-of-line item. OpenResume starts a new line only at &lt;code&gt;hasEOL&lt;/code&gt;, so with 7.4 the city ran into the next line: the job title came back as &lt;code&gt;New York, NYInvestment Banking Analyst Intern&lt;/code&gt;, and the parser found six jobs instead of three. I've only tested these two versions, so I can't say where in between it changed.&lt;/p&gt;

&lt;h2&gt;
  
  
  LaTeX: you write the text layer yourself
&lt;/h2&gt;

&lt;p&gt;With Writer or Google Docs you get whatever text layer the exporter writes. In LaTeX it's set in the class file. The parts of &lt;code&gt;atsresume.cls&lt;/code&gt; that matter here, trimmed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tex"&gt;&lt;code&gt;% pdfLaTeX
\DisableLigatures[f]{encoding = *}   % microtype: fi and fl stay two glyphs
\input{glyphtounicode}
\pdfgentounicode=1                   % every glyph maps back to Unicode
% LuaLaTeX and XeLaTeX
\setmainfont{texgyrepagella}[..., Ligatures = {TeX, NoCommon}]
% no word split across lines
\hyphenpenalty=10000
\exhyphenpenalty=10000
% places and dates: pushed right with glue, not a table
\unskip\nobreak\hfil\penalty50\hskip1em\hbox{}\nobreak\hfil
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The example resume uses the same person and text as Classic. Compiled with pdfLaTeX, LuaLaTeX and XeLaTeX, on Letter and A4, all six PDFs read 38 of 38 with zero ligature glyphs. The full check (18 PDFs including edge cases, under TeX Live 2026 and the TeX Live packages in Debian 12 and Ubuntu 22.04) passed with all three.&lt;/p&gt;

&lt;p&gt;Two differences showed up anyway. TeX turns a typed apostrophe into a curly one, so "professor's" comes out as &lt;code&gt;professor’s&lt;/code&gt;. That was the one change our expected values needed. And the extractor matters: &lt;code&gt;pdftotext -layout&lt;/code&gt; kept every place and date beside its line, while plain &lt;code&gt;pdftotext&lt;/code&gt; guessed at columns and moved "Providence, RI" and "Sep 2023 – Dec 2024" elsewhere in their entries, usually after the bullets. Same PDF, different reading order, depending on the tool.&lt;/p&gt;

&lt;h2&gt;
  
  
  Google Docs, for comparison
&lt;/h2&gt;

&lt;p&gt;Google Docs gives you the least control over the text layer. In our tests, 16 of 32 fonts saved letter pairs as ligatures, and &lt;a href="https://readbyaparser.beehiiv.com/p/what-a-resume-parser-reads-from-a-google-docs-pdf" rel="noopener noreferrer"&gt;a text box that Google Docs exported as a picture&lt;/a&gt; took the name and contact details out of the text entirely (34 of 46 fields). I went through how the Google Docs side is tested in &lt;a href="https://dev.to/superlede/testing-google-docs-resume-pdfs-against-an-open-source-parser-ligatures-page-breaks-and-a-missing-3k21"&gt;an earlier post&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'd check on any export
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Run &lt;code&gt;pdffonts&lt;/code&gt; on the PDF. If the font in the PDF isn't the one you picked, find out what replaced it first.&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;multi_char_glyphs()&lt;/code&gt; and look at what each glyph maps to. Compare each glyph's extracted text with the letters it represents. In the Libertine export, the glyph for &lt;code&gt;fi&lt;/code&gt; returned &lt;code&gt;fir&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Dump pdf.js text items for one entry and check that each line ends with a &lt;code&gt;hasEOL&lt;/code&gt; item.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Limits: one parser, one sample per template, US Letter. "Font missing" was simulated with a headless run, and the LibreOffice 7.4 result is one export on one machine.&lt;/p&gt;




&lt;p&gt;I run ReadableResume. More on &lt;a href="https://readableresume.com/how-we-test" rel="noopener noreferrer"&gt;how the templates are tested against resume parsers&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I used AI to help draft this post.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>pdf</category>
      <category>latex</category>
      <category>libreoffice</category>
      <category>testing</category>
    </item>
    <item>
      <title>What a "ChatGPT watermark remover" actually removes, and what it did to 100 AI scores</title>
      <dc:creator>SuperLede</dc:creator>
      <pubDate>Mon, 16 Nov 2026 18:52:56 +0000</pubDate>
      <link>https://dev.to/superlede/what-a-chatgpt-watermark-remover-actually-removes-and-what-it-did-to-100-ai-scores-32j9</link>
      <guid>https://dev.to/superlede/what-a-chatgpt-watermark-remover-actually-removes-and-what-it-did-to-100-ai-scores-32j9</guid>
      <description>&lt;p&gt;We built a browser-based &lt;a href="https://aicheckerhumanizer.com/chatgpt-watermark-remover" rel="noopener noreferrer"&gt;ChatGPT watermark remover&lt;/a&gt; that strips hidden Unicode characters. Then we tested whether cleaning changed the scores from our AI detector.&lt;/p&gt;

&lt;p&gt;Short version: for 96 of 100 texts the score stayed within 5 points.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two different things get called a "watermark"
&lt;/h2&gt;

&lt;p&gt;A real text watermark is statistical. The model nudges which words it picks, and a verifier with the key can spot the pattern later. There are no extra characters to find. As of November 11, 2026:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;OpenAI says verification of its text marks is available only to approved organizations, such as research and academic institutions.&lt;/li&gt;
&lt;li&gt;Google watermarks text from the Gemini app and website with SynthID.&lt;/li&gt;
&lt;li&gt;Anthropic says recent Claude models and some older ones add a text watermark.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;No character cleaner can touch any of these, because there is nothing in the string to delete.&lt;/p&gt;

&lt;p&gt;Hidden characters are a separate thing. Zero-width spaces, odd-width spaces and soft hyphens come along when you copy from a chat window, a PDF or a web page. They aren't a signature. They do break code, mess up line wrapping in a CMS and throw off word counts.&lt;/p&gt;

&lt;h2&gt;
  
  
  What our cleaner looks for
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Character&lt;/th&gt;
&lt;th&gt;Code&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Zero-width space, non-joiner, joiner&lt;/td&gt;
&lt;td&gt;U+200B to U+200D&lt;/td&gt;
&lt;td&gt;Removed (the joiner is kept inside emoji like 👨‍👩‍👧)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Word joiner, byte order mark&lt;/td&gt;
&lt;td&gt;U+2060, U+FEFF&lt;/td&gt;
&lt;td&gt;Removed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Soft hyphen&lt;/td&gt;
&lt;td&gt;U+00AD&lt;/td&gt;
&lt;td&gt;Removed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Thin, hair, en, em and other fixed-width spaces&lt;/td&gt;
&lt;td&gt;U+2000 to U+200A&lt;/td&gt;
&lt;td&gt;Replaced with a normal space&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Narrow no-break space&lt;/td&gt;
&lt;td&gt;U+202F&lt;/td&gt;
&lt;td&gt;Replaced with a normal space&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cyrillic or Greek letters inside English words&lt;/td&gt;
&lt;td&gt;e.g. U+0430 а&lt;/td&gt;
&lt;td&gt;Replaced with the Latin letter&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No-break space&lt;/td&gt;
&lt;td&gt;U+00A0&lt;/td&gt;
&lt;td&gt;Kept, because it often belongs there, as in "Mr. Smith"&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Find them yourself in 20 lines
&lt;/h2&gt;

&lt;p&gt;You don't need our tool to see what's in a string. This is a cut-down version of the check, plain JavaScript, no dependencies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;NAMES&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="mh"&gt;0x200b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"zero-width space"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x200c&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"zero-width non-joiner"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x200d&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"zero-width joiner"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="mh"&gt;0x2060&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"word joiner"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0xfeff&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"byte order mark"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x00ad&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"soft hyphen"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="mh"&gt;0x202f&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"narrow no-break space"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x205f&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"medium mathematical space"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x3000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"ideographic space"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;isOddSpace&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;cp&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mh"&gt;0x2000&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;cp&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mh"&gt;0x200a&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;isLookAlike&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ch&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;\&lt;span class="n"&gt;u0400&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;\&lt;span class="n"&gt;u04FF&lt;/span&gt;\&lt;span class="n"&gt;u0370&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;\&lt;span class="n"&gt;u03FF&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ch&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Cyrillic or Greek&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;findHidden&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;hits&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="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ch&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;cp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;codePointAt&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="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;NAMES&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;cp&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;isOddSpace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s2"&gt;"fixed-width space"&lt;/span&gt;
      &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;isLookAlike&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ch&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="sb"&gt;`look-alike letter "${ch}"`&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;hits&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"U+"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;cp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toUpperCase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;padStart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"0"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;hits&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;sample&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"The res\u200Bults were cle\u00ADar:\u202Fthe m\u043Edel did better\u2009than expected."&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;table&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;findHidden&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sample&lt;/span&gt;&lt;span class="p"&gt;)&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;Running it with Node prints:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌─────────┬───────┬──────────┬─────────────────────────┐
│ (index) │ index │ code     │ name                    │
├─────────┼───────┼──────────┼─────────────────────────┤
│ 0       │ 7     │ 'U+200B' │ 'zero-width space'      │
│ 1       │ 21    │ 'U+00AD' │ 'soft hyphen'           │
│ 2       │ 25    │ 'U+202F' │ 'narrow no-break space' │
│ 3       │ 31    │ 'U+043E' │ 'look-alike letter "о"' │
│ 4       │ 46    │ 'U+2009' │ 'fixed-width space'     │
└─────────┴───────┴──────────┴─────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Printed, that sample looks ordinary. It contains a zero-width space, a soft hyphen, two unusual spaces and a Cyrillic "о".&lt;/p&gt;

&lt;p&gt;The look-alike check here is crude: it flags every Cyrillic or Greek letter, which is wrong for text that is actually Russian or Greek. The version on our page only flags them inside otherwise Latin words.&lt;/p&gt;

&lt;h2&gt;
  
  
  Does cleaning change an AI score?
&lt;/h2&gt;

&lt;p&gt;We wanted to know whether it does, so we measured it on our own detector.&lt;/p&gt;

&lt;p&gt;We took 100 AI-written texts and made a copy of each with hidden characters added: zero-width spaces, unusual spaces, soft hyphens and a few look-alike letters, about 59 per text. We scored the copy with hidden characters and the cleaned version 3 times each, without using saved results, and compared the averages.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Score change after cleaning (cleaned minus with hidden characters)&lt;/th&gt;
&lt;th&gt;Points out of 100&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Median change&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Middle 80% of texts&lt;/td&gt;
&lt;td&gt;-0.7 to 0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Largest drop and rise&lt;/td&gt;
&lt;td&gt;-33.0 and +0.3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Texts within 5 points&lt;/td&gt;
&lt;td&gt;96 of 100&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Texts whose verdict changed&lt;/td&gt;
&lt;td&gt;3 of 100&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Our detector only, engine version w0p5-38c6d591, November 11, 2026. Other detectors may behave differently; we didn't test them.&lt;/p&gt;

&lt;p&gt;The other four texts dropped by more than 5 points; the largest drop was 33 points, and three verdicts changed. No text went up by more than 0.3. We averaged three runs per version because scores vary between runs. We didn't compare cleaning with changes to the wording.&lt;/p&gt;

&lt;h2&gt;
  
  
  When cleaning is worth it
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Code.&lt;/strong&gt; A zero-width space inside a variable name, or a thin space in an indent, gives you a syntax error you can stare at for an hour.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CMS and email.&lt;/strong&gt; Pasted text that won't wrap, or wraps in the wrong place, often has fixed-width or no-break spaces in it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Word and character limits.&lt;/strong&gt; Invisible characters still count toward form limits and some word counters.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Search and matching.&lt;/strong&gt; "results" with a zero-width space in the middle won't match "results".&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If any of that sounds familiar, paste the text into a checker or run the snippet above before you go hunting for a bug that isn't in your logic.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I used AI to help draft this post.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>javascript</category>
      <category>unicode</category>
      <category>writing</category>
    </item>
    <item>
      <title>What we write down after every database restore drill</title>
      <dc:creator>SuperLede</dc:creator>
      <pubDate>Sun, 15 Nov 2026 08:11:11 +0000</pubDate>
      <link>https://dev.to/superlede/what-we-write-down-after-every-database-restore-drill-1b6j</link>
      <guid>https://dev.to/superlede/what-we-write-down-after-every-database-restore-drill-1b6j</guid>
      <description>&lt;p&gt;A restore drill that passes tells you that one backup restored on one day. That's worth knowing, but most of what drills can teach you only shows up when you compare them: restore times that creep up quarter after quarter, a table whose row count stopped matching after a migration, a role someone creates by hand every time and never mentions. If the only record is a green check in CI, none of that survives.&lt;/p&gt;

&lt;p&gt;We built backupdrill, which runs restore drills for Supabase projects. Whether the backup ran at all is a monitoring question, and I covered &lt;a href="https://builder.aws.com/content/3LpX9QnVkOpLakQ47df0gW8We48/get-alerted-when-your-supabase-backup-to-s3-fails-or-never-runs" rel="noopener noreferrer"&gt;alerts when a Supabase backup to S3 fails or never runs&lt;/a&gt; in an earlier post. This log records which backup restored, what was checked, and how long it took.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fields
&lt;/h2&gt;

&lt;p&gt;We put these fields into a free &lt;a href="https://tally.so/templates/database-restore-drill-log/mZBx5m" rel="noopener noreferrer"&gt;restore drill log template&lt;/a&gt; on Tally, one form submission per drill.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Field&lt;/th&gt;
&lt;th&gt;Why it's there&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Drill date, who ran it&lt;/td&gt;
&lt;td&gt;So you can ask that person what they did by hand.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Database or project&lt;/td&gt;
&lt;td&gt;One log usually covers several.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Which backup was restored&lt;/td&gt;
&lt;td&gt;File name or snapshot time. "The latest" doesn't let anyone repeat the drill next month.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Where it was restored&lt;/td&gt;
&lt;td&gt;Local Docker, staging, or a new cloud project. Note the target before comparing restore times.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Restore time in minutes&lt;/td&gt;
&lt;td&gt;The number someone will ask you for during an outage.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;What was checked&lt;/td&gt;
&lt;td&gt;Restore finished without errors, table count matches, row counts on key tables, app connects, uploaded files are there.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Result&lt;/td&gt;
&lt;td&gt;Passed, passed with issues, or failed.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;What went wrong, what to fix before next time&lt;/td&gt;
&lt;td&gt;Fixes to check at the next drill.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two of these need more than a line.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Where you restored it.&lt;/strong&gt; A throwaway Docker Postgres with durability switched off restores much faster than a real database. In our own benchmark, the same 1 GB restore took 61 seconds with &lt;code&gt;fsync&lt;/code&gt;, &lt;code&gt;synchronous_commit&lt;/code&gt; and &lt;code&gt;full_page_writes&lt;/code&gt; off, and 110 seconds on stock PostgreSQL settings. If one drill ran on a laptop and the next on staging, the timing difference may come from the target, not the backup.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Passed with issues.&lt;/strong&gt; This is the result I'd read first. A drill where someone had to create a missing role, re-run a step or skip a table "because it's only logs" passed in the sense that the data came back. In a real recovery those steps happen under pressure, possibly by someone who has never seen them. Written down, they can be fixed or scripted before the next drill.&lt;/p&gt;

&lt;h2&gt;
  
  
  Restore time: measure it, don't derive it from the dump
&lt;/h2&gt;

&lt;p&gt;Dump size alone doesn't tell you how long index builds and foreign-key checks will take. A custom-format dump carries index definitions, not indexes, so the restore builds every one of them from scratch and checks every foreign key again.&lt;/p&gt;

&lt;p&gt;When we timed restores of a 10 GB PostgreSQL 17 database on a 2 vCPU / 8 GB VM, the dump was 1.74 GiB and a single-job &lt;code&gt;pg_restore&lt;/code&gt; took 12.1 minutes. Across our drill restores of that database, 77% of the time (559 seconds) went to indexes, constraints and foreign keys. Loading all 18.8 million rows took 163.&lt;/p&gt;

&lt;p&gt;The restore step isn't the whole recovery either. For the same database, the drill's restore step averaged 721.6 seconds, while the full drill, which also downloads the dump, starts the database and checks every table, took 795.3. Log the number that answers the question you'll get. For "how long until we're back", that's the end-to-end time, plus however long it takes to point the app at the new database.&lt;/p&gt;

&lt;h2&gt;
  
  
  Row counts: compare exactly, and against the backup
&lt;/h2&gt;

&lt;p&gt;"Row counts spot-checked on key tables" is the weakest line on the checklist, because spot checks drift toward "looks about right". Two changes make it worth doing.&lt;/p&gt;

&lt;p&gt;Compare against the backup, not production. Production has moved on since the dump was taken, so a difference of a few hundred rows doesn't show whether the restore lost data. &lt;code&gt;pg_dump&lt;/code&gt; exports from one consistent snapshot, so the per-table counts in the dump are exactly what should come back.&lt;/p&gt;

&lt;p&gt;For ordinary tables in the backup, including leaf partitions, &lt;code&gt;backupdrill drill&lt;/code&gt; compares restored row counts with the counts read from the dump and fails on any difference. Materialized views, partitioned parents and extension-owned tables are excluded from this exact comparison; they are only checked for being non-empty. It doesn't query production for this; it reads the dump one extra time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let the drill write the machine half
&lt;/h2&gt;

&lt;p&gt;Nobody should be typing restore seconds into a form when the tool already has them. &lt;code&gt;backupdrill drill&lt;/code&gt; prints its checks to stderr and one JSON line to stdout, so you can keep the whole report:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;backupdrill drill &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; drill-&lt;span class="nv"&gt;$(&lt;/span&gt;date -u +%F&lt;span class="o"&gt;)&lt;/span&gt;.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The report holds the snapshot name, the result, every check with its detail, the restore time, and how many tables and rows were restored. Pulling out what the log needs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;jq -r &lt;span class="s1"&gt;'.report | [.snapshot, .pass, .restoreSeconds, .restoredTableCount, .restoredRowTotal] | @tsv'&lt;/span&gt; drill-2026-11-15.json
jq -r &lt;span class="s1"&gt;'.report.checks[] | "\(if .pass then "ok  " else "FAIL" end) \(.name): \(.detail)"'&lt;/span&gt; drill-2026-11-15.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The check names map onto the template's checklist: &lt;code&gt;archive integrity&lt;/code&gt; (the dump's sha256 against the manifest), &lt;code&gt;table count&lt;/code&gt;, &lt;code&gt;no missing tables&lt;/code&gt;, &lt;code&gt;populated tables came back&lt;/code&gt; and &lt;code&gt;row counts match the backup&lt;/code&gt;. If you pass &lt;code&gt;--check-cmd "npm run smoke"&lt;/code&gt;, your own test runs against the restored copy and shows up as &lt;code&gt;app checks&lt;/code&gt;. The command exits 1 when any check fails.&lt;/p&gt;

&lt;p&gt;Add &lt;code&gt;--record&lt;/code&gt; and the drill also writes a small file to your bucket under &lt;code&gt;&amp;lt;prefix&amp;gt;/&amp;lt;project&amp;gt;.drills/&lt;/code&gt;, named after the time it finished and whether it passed. It looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"schemaVersion"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"tool"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"backupdrill-cli"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"toolVersion"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2.11.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"finishedAt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2026-11-15T04:12:09.311Z"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"pass"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"snapshot"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2026-11-15T03-00-12-418Z"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"restoreSeconds"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;69.1&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 build your own version of this, two of its decisions are worth copying. Each drill writes a new file instead of overwriting a "latest result" object, because two overlapping drills can finish in one order and write in the other, and an older pass would then hide a newer failure. And a failed drill records no restore time, since a number from a restore that stopped halfway would make the next estimate look better than it is. Check details stay out of the file too: a failure message can quote table data, and more people may be able to read the bucket than the drill logs. &lt;code&gt;backupdrill exporter&lt;/code&gt; reads these files and exposes when the last drill ran and whether it passed as Prometheus metrics.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the human half is for
&lt;/h2&gt;

&lt;p&gt;The JSON records what this drill checked. Use the log to note checks you ran separately and anything you still need to test.&lt;/p&gt;

&lt;p&gt;For snapshots without Auth users, our drill sandbox has no &lt;code&gt;auth.users&lt;/code&gt; table. A &lt;code&gt;profiles&lt;/code&gt; table with rows that reference it can pass the drill, because the foreign key is reported as a skipped Supabase-managed object, and then fail in a new project where &lt;code&gt;auth.users&lt;/code&gt; is empty. &lt;code&gt;backupdrill restore --dry-run&lt;/code&gt; against the real target catches it. The drill log is where "passed, but a restore into a new project needs the users copied in first" gets written down.&lt;/p&gt;

&lt;p&gt;Storage is similar. Unless you pass &lt;code&gt;--verify-all-files&lt;/code&gt;, the drill checksums a random sample of up to 100 files. If particular files matter to you, check those before you tick "uploaded files are there".&lt;/p&gt;

&lt;h2&gt;
  
  
  Reading the log
&lt;/h2&gt;

&lt;p&gt;Every quarter or so, read the log top to bottom. Are restore minutes growing faster than the data? Is any "passed with issues" fix still open from more than one drill ago? When did each project last pass? If you don't use the CLI, our guide on &lt;a href="https://backupdrill.com/guides/test-supabase-backup-restore" rel="noopener noreferrer"&gt;how to test that a Supabase backup actually restores&lt;/a&gt; walks through the same drill by hand with Docker and &lt;code&gt;pg_restore&lt;/code&gt;, and the same log works for it.&lt;/p&gt;




&lt;p&gt;We built BackupDrill. The CLI used here is MIT licensed: &lt;a href="https://github.com/backupdrill/cli" rel="noopener noreferrer"&gt;https://github.com/backupdrill/cli&lt;/a&gt;&lt;/p&gt;

</description>
      <category>postgres</category>
      <category>supabase</category>
      <category>devops</category>
      <category>sre</category>
    </item>
    <item>
      <title>Backing up a Supabase Free project every week with GitHub Actions</title>
      <dc:creator>SuperLede</dc:creator>
      <pubDate>Sat, 07 Nov 2026 08:28:38 +0000</pubDate>
      <link>https://dev.to/superlede/backing-up-a-supabase-free-project-every-week-with-github-actions-fgd</link>
      <guid>https://dev.to/superlede/backing-up-a-supabase-free-project-every-week-with-github-actions-fgd</guid>
      <description>&lt;p&gt;The Supabase Free plan doesn't give you access to daily backups. Access starts on Pro. The official advice for Free projects is to export your data regularly with the CLI and keep a copy somewhere else. Manual exports are easy to forget.&lt;/p&gt;

&lt;p&gt;A prototype or side project can become a tool a client relies on. Free projects can still be paused after a week of inactivity.&lt;/p&gt;

&lt;p&gt;Here's the setup I'd use: a GitHub Actions workflow that runs once a week and writes the dump to a bucket you own.&lt;/p&gt;

&lt;h2&gt;
  
  
  The workflow
&lt;/h2&gt;

&lt;p&gt;You need a private GitHub repo, a bucket on Cloudflare R2, AWS S3 or Backblaze B2, and your project's Session pooler connection string (dashboard, Connect button, Session pooler).&lt;/p&gt;

&lt;p&gt;Save this as &lt;code&gt;.github/workflows/scheduled-backup.yml&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;scheduled-backup&lt;/span&gt;

&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;schedule&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;cron&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;0&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;3&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;*&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;*&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;0"&lt;/span&gt; &lt;span class="c1"&gt;# Sundays at 03:00 UTC&lt;/span&gt;
  &lt;span class="na"&gt;workflow_dispatch&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;{}&lt;/span&gt; &lt;span class="c1"&gt;# run it by hand from the Actions tab&lt;/span&gt;

&lt;span class="na"&gt;permissions&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;contents&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;read&lt;/span&gt;

&lt;span class="na"&gt;concurrency&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;group&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;backupdrill-scheduled&lt;/span&gt;
  &lt;span class="na"&gt;cancel-in-progress&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;

&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;backup&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Install postgresql-client-17 (PGDG)&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
          &lt;span class="s"&gt;sudo install -d /usr/share/postgresql-common/pgdg&lt;/span&gt;
          &lt;span class="s"&gt;curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc \&lt;/span&gt;
            &lt;span class="s"&gt;| sudo gpg --dearmor -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.gpg&lt;/span&gt;
          &lt;span class="s"&gt;echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.gpg] \&lt;/span&gt;
          &lt;span class="s"&gt;https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" \&lt;/span&gt;
            &lt;span class="s"&gt;| sudo tee /etc/apt/sources.list.d/pgdg.list&lt;/span&gt;
          &lt;span class="s"&gt;sudo apt-get update&lt;/span&gt;
          &lt;span class="s"&gt;sudo apt-get install -y postgresql-client-17&lt;/span&gt;

      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Tell backupdrill where pg_dump 17 lives&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;echo "BACKUPDRILL_PG_DUMP=/usr/lib/postgresql/17/bin/pg_dump" &amp;gt;&amp;gt; "$GITHUB_ENV"&lt;/span&gt;

      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/setup-node@v4&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;node-version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;20"&lt;/span&gt;

      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Run backupdrill&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npx -y backupdrill@2.10.1 backup&lt;/span&gt;
        &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;BACKUPDRILL_DATABASE_URL&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.BACKUPDRILL_DATABASE_URL }}&lt;/span&gt;
          &lt;span class="na"&gt;BACKUPDRILL_S3_BUCKET&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.BACKUPDRILL_S3_BUCKET }}&lt;/span&gt;
          &lt;span class="na"&gt;BACKUPDRILL_S3_ACCESS_KEY_ID&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.BACKUPDRILL_S3_ACCESS_KEY_ID }}&lt;/span&gt;
          &lt;span class="na"&gt;BACKUPDRILL_S3_SECRET_ACCESS_KEY&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.BACKUPDRILL_S3_SECRET_ACCESS_KEY }}&lt;/span&gt;
          &lt;span class="na"&gt;BACKUPDRILL_S3_ENDPOINT&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.BACKUPDRILL_S3_ENDPOINT }}&lt;/span&gt;
          &lt;span class="na"&gt;BACKUPDRILL_S3_REGION&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.BACKUPDRILL_S3_REGION }}&lt;/span&gt;
          &lt;span class="na"&gt;BACKUPDRILL_PING_URL&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.BACKUPDRILL_PING_URL }}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The PGDG step is there because &lt;code&gt;pg_dump&lt;/code&gt;'s major version has to be at least your Postgres version, and the client on the runner can be older than your database.&lt;/p&gt;

&lt;p&gt;Add the four required values as repository secrets: the pooler string with your password in it, the bucket name, and an access key pair scoped to that one bucket. R2 and B2 also need the endpoint and region. Then open the Actions tab and run it once by hand.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;backupdrill&lt;/code&gt; is an open-source CLI that wraps &lt;code&gt;pg_dump&lt;/code&gt; and writes a checksummed manifest next to the dump. The dump itself is plain custom format, so stock &lt;code&gt;pg_restore&lt;/code&gt; can read it. If you'd rather call &lt;code&gt;pg_dump&lt;/code&gt; yourself, the rest of this post still applies.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why weekly and not daily
&lt;/h2&gt;

&lt;p&gt;Every backup streams your data out of Supabase and counts against the Free plan's 5 GB of monthly egress, which your app shares. Free databases are capped at 500 MB. If each backup moved the full 500 MB, four weekly runs would use about 2 GB and 30 daily runs about 15 GB, three times the allowance. Your real number depends on your database.&lt;/p&gt;

&lt;p&gt;Keep &lt;code&gt;workflow_dispatch&lt;/code&gt; so you can take an extra backup before a risky migration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check that the backups keep running
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;A public repo.&lt;/strong&gt; GitHub turns off scheduled workflows in public repos after 60 days without activity, and a backup repo is exactly the kind of repo that goes quiet. Private repos don't have that rule.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;An unchecked Actions tab.&lt;/strong&gt; A failed scheduled run is easy to miss. Create a weekly Healthchecks.io check, choose who gets the alert, and store its ping URL as the &lt;code&gt;BACKUPDRILL_PING_URL&lt;/code&gt; secret. The workflow above already passes it to the backup step.&lt;/p&gt;

&lt;h2&gt;
  
  
  A green run isn't a restore
&lt;/h2&gt;

&lt;p&gt;Green means the backup command finished successfully. It hasn't tested whether the dump restores. Before you trust this, restore a snapshot somewhere disposable, either with &lt;code&gt;pg_restore&lt;/code&gt; into a scratch Postgres or with &lt;code&gt;backupdrill drill&lt;/code&gt;, which pulls the latest snapshot into a throwaway Docker Postgres and checks it against the manifest.&lt;/p&gt;

&lt;p&gt;Also check what's in scope. The dump covers the &lt;code&gt;public&lt;/code&gt; schema by default, and it doesn't bring back Storage files. Those need their own S3 keys in the workflow.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://backupdrill.com/guides/supabase-backup-github-actions" rel="noopener noreferrer"&gt;full guide to Supabase backups with GitHub Actions&lt;/a&gt; has the Storage setup, the bucket click-paths and what happens if you go over the egress allowance.&lt;/p&gt;

&lt;p&gt;I work on BackupDrill, so I'm biased toward testing restores. The CLI is MIT licensed: &lt;a href="https://github.com/backupdrill/cli" rel="noopener noreferrer"&gt;https://github.com/backupdrill/cli&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I used AI to help draft this post.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>supabase</category>
      <category>postgres</category>
      <category>githubactions</category>
      <category>devops</category>
    </item>
    <item>
      <title>Per-customer rate limits and 429s in Express and FastAPI</title>
      <dc:creator>SuperLede</dc:creator>
      <pubDate>Sun, 01 Nov 2026 16:37:23 +0000</pubDate>
      <link>https://dev.to/superlede/per-customer-rate-limits-and-429s-in-express-and-fastapi-1ib0</link>
      <guid>https://dev.to/superlede/per-customer-rate-limits-and-429s-in-express-and-fastapi-1ib0</guid>
      <description>&lt;p&gt;Most rate limiting tutorials limit by IP address. That's the right tool for a login form, and the wrong one for an API that customers pay for. A customer's traffic can come from fifty servers behind fifty addresses, or from one office NAT shared with someone else's script. What you want to cap is the customer: "Acme gets 5 requests per second, however many keys or machines they use."&lt;/p&gt;

&lt;p&gt;This post builds that in Express and in FastAPI with nothing but the framework, then covers the 429 response and the parts that tend to go wrong: ordering, retries and running more than one process.&lt;/p&gt;

&lt;h2&gt;
  
  
  A token bucket per customer
&lt;/h2&gt;

&lt;p&gt;A token bucket is two numbers per customer: how many tokens are in the bucket, and when you last looked. The bucket holds at most &lt;code&gt;capacity&lt;/code&gt; tokens and refills at &lt;code&gt;refillPerSecond&lt;/code&gt;. Each request takes one token; an empty bucket means 429. A customer who's been quiet can send a burst of &lt;code&gt;capacity&lt;/code&gt; requests, then continues at the refill rate.&lt;/p&gt;

&lt;p&gt;You don't need a timer. Refill lazily when a request arrives:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// rate-limit.js&lt;/span&gt;
&lt;span class="c1"&gt;// One token bucket per customer. Refilled lazily when a request arrives, so no timers.&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;tokenBucket&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;capacity&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;refillPerSecond&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;now&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;performance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;buckets&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Map&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// customerId -&amp;gt; { tokens, updatedAt }&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;take&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;customerId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;time&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bucket&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;buckets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;customerId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;tokens&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;capacity&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;updatedAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;time&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="nx"&gt;bucket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tokens&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;capacity&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;bucket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tokens&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;time&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;bucket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;updatedAt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;refillPerSecond&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;bucket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;updatedAt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;time&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;buckets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;customerId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;bucket&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bucket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tokens&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// Round up: a client that retries a moment too early just gets another 429&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;allowed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;retryAfter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ceil&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;bucket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tokens&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nx"&gt;refillPerSecond&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;bucket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tokens&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="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;allowed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;remaining&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bucket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tokens&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;};&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;Two details matter here. The clock is &lt;code&gt;performance.now()&lt;/code&gt;, which is monotonic, so an NTP adjustment can't refill or drain every bucket at once. And &lt;code&gt;retryAfter&lt;/code&gt; is rounded up, because telling a client to come back in 0 seconds produces a retry that fails again.&lt;/p&gt;

&lt;h2&gt;
  
  
  Express: authenticate first, then limit
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// app.js&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;express&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;tokenBucket&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./rate-limit.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Stand-in for your key table. Acme has two keys but one bucket.&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;KEYS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Map&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;key_acme_1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;acme&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;key_acme_2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;acme&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;key_globex&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;globex&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;CAPACITY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;take&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;tokenBucket&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;capacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;CAPACITY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;refillPerSecond&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;authenticate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;authorization&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)?.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/^Bearer&lt;/span&gt;&lt;span class="se"&gt;\s&lt;/span&gt;&lt;span class="sr"&gt;+/i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;customerId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;KEYS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;customerId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;401&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;invalid_api_key&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;customerId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;customerId&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;rateLimit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;take&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;customerId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;RateLimit-Policy&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;`"default";q=&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;CAPACITY&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;;w=&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;CAPACITY&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;allowed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Retry-After&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;retryAfter&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;RateLimit&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;`"default";r=0;t=&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;retryAfter&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;429&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;rate_limited&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;retry_after&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;retryAfter&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;express&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/health&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ok&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// before the limiter: never limited&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/v1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;authenticate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;rateLimit&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/v1/things&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;customerId&lt;/span&gt; &lt;span class="p"&gt;}));&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Send six requests in a row, alternating Acme's two keys, and the sixth gets:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="k"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;1.1&lt;/span&gt; &lt;span class="m"&gt;429&lt;/span&gt; &lt;span class="ne"&gt;Too Many Requests&lt;/span&gt;
&lt;span class="na"&gt;RateLimit-Policy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"default";q=5;w=5&lt;/span&gt;
&lt;span class="na"&gt;Retry-After&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;1&lt;/span&gt;
&lt;span class="na"&gt;RateLimit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"default";r=0;t=1&lt;/span&gt;

{"error":"rate_limited","retry_after":1}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Globex is unaffected, because it has its own bucket.&lt;/p&gt;

&lt;p&gt;The order of &lt;code&gt;authenticate&lt;/code&gt; and &lt;code&gt;rateLimit&lt;/code&gt; is the whole point. Authentication runs first for two reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The bucket key has to be the customer, not the API key string.&lt;/strong&gt; Key it on the key and a customer with five keys gets five times the limit. You only know the customer after authentication.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unknown keys should never reach the limiter.&lt;/strong&gt; If they did, anyone could fill your &lt;code&gt;Map&lt;/code&gt; with junk keys. Junk keys get a 401 instead. (If you're worried about key guessing, add a per-IP limit on failed authentications at the edge.)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Also note that Express middleware only applies to routes registered after it. &lt;code&gt;/health&lt;/code&gt; above is open on purpose; a router mounted in some earlier file would be open by accident.&lt;/p&gt;

&lt;h2&gt;
  
  
  FastAPI: dependencies, and why they should be async
&lt;/h2&gt;

&lt;p&gt;In FastAPI the natural place for this is a dependency chain: one dependency resolves the customer, the next one spends a token.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# main.py
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;fastapi&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Depends&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;FastAPI&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Header&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;HTTPException&lt;/span&gt;

&lt;span class="c1"&gt;# Stand-in for your key table. Acme has two keys but one bucket.
&lt;/span&gt;&lt;span class="n"&gt;KEYS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;key_acme_1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;acme&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;key_acme_2&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;acme&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;key_globex&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;globex&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;CAPACITY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="n"&gt;REFILL_PER_SECOND&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;
&lt;span class="n"&gt;buckets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;tuple&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;  &lt;span class="c1"&gt;# customer_id -&amp;gt; (tokens, updated_at)
&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;take&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customer_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;tuple&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
    &lt;span class="n"&gt;now&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;monotonic&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;tokens&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;updated_at&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;buckets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customer_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;CAPACITY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="n"&gt;tokens&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;CAPACITY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tokens&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;now&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;updated_at&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;REFILL_PER_SECOND&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;tokens&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;buckets&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;customer_id&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tokens&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ceil&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;tokens&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;REFILL_PER_SECOND&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;buckets&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;customer_id&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tokens&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="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;


&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;current_customer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;authorization&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Header&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;default&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;""&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;scheme&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;authorization&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;partition&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;customer_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;KEYS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;scheme&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;bearer&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;customer_id&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;HTTPException&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;401&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;detail&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;invalid_api_key&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;customer_id&lt;/span&gt;


&lt;span class="c1"&gt;# async def on purpose: a plain def dependency runs in a thread pool,
# and two threads could both spend the last token.
&lt;/span&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;rate_limited&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customer_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Depends&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current_customer&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;allowed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;retry_after&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;take&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customer_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;allowed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;HTTPException&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="mi"&gt;429&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;detail&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;rate_limited&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Retry-After&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;retry_after&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
                &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;RateLimit-Policy&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;'"&lt;/span&gt;&lt;span class="s"&gt;default&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;;q=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;CAPACITY&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;;w=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ceil&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;CAPACITY&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;REFILL_PER_SECOND&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;RateLimit&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;'"&lt;/span&gt;&lt;span class="s"&gt;default&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;;r=0;t=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;retry_after&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;customer_id&lt;/span&gt;


&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;FastAPI&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;


&lt;span class="nd"&gt;@app.get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/v1/things&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;things&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customer_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Depends&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rate_limited&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;customer&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;customer_id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it with &lt;code&gt;uvicorn main:app&lt;/code&gt; and the sixth quick request gets a 429 with the same three headers, and a body of &lt;code&gt;{"detail":"rate_limited"}&lt;/code&gt;. FastAPI wraps &lt;code&gt;HTTPException&lt;/code&gt; details in &lt;code&gt;detail&lt;/code&gt;; add an exception handler if you want the same body shape as the Express version.&lt;/p&gt;

&lt;p&gt;Two FastAPI-specific notes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;async def&lt;/code&gt; is doing real work here.&lt;/strong&gt; FastAPI runs plain &lt;code&gt;def&lt;/code&gt; dependencies in a thread pool. The read-modify-write in &lt;code&gt;take()&lt;/code&gt; isn't atomic, so two threads can read the same bucket and both spend its last token. An &lt;code&gt;async def&lt;/code&gt; dependency runs on the event loop, and &lt;code&gt;take()&lt;/code&gt; has no &lt;code&gt;await&lt;/code&gt; in it, so nothing else can run in the middle. If you need a sync dependency, put a &lt;code&gt;threading.Lock&lt;/code&gt; around the bucket update.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A dependency can't limit what it doesn't run on.&lt;/strong&gt; Routes that don't declare &lt;code&gt;Depends(rate_limited)&lt;/code&gt; aren't limited. If you'd rather cover everything under a prefix, put the dependency on the &lt;code&gt;APIRouter&lt;/code&gt; (&lt;code&gt;APIRouter(dependencies=[Depends(rate_limited)])&lt;/code&gt;). If you move the check into a middleware instead, remember that middlewares run before dependencies, so the customer has to be resolved in a middleware too.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What the 429 should carry
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;Retry-After&lt;/code&gt; in seconds.&lt;/strong&gt; It tells the client how many seconds to wait before retrying. Seconds don't depend on the client's clock being right, which an HTTP date does.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;RateLimit-Policy&lt;/code&gt; and &lt;code&gt;RateLimit&lt;/code&gt;.&lt;/strong&gt; These come from an IETF draft (draft-ietf-httpapi-ratelimit-headers). &lt;code&gt;q&lt;/code&gt; is the bucket size and &lt;code&gt;w&lt;/code&gt; its window in seconds; &lt;code&gt;r&lt;/code&gt; is what's left and &lt;code&gt;t&lt;/code&gt; is when to try again. It's still a draft and the field names have changed over the revisions, so treat them as a bonus and &lt;code&gt;Retry-After&lt;/code&gt; as the one clients should rely on.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A machine-readable &lt;code&gt;error&lt;/code&gt; code in the body&lt;/strong&gt;, so clients can tell a rate limit apart from other 429s.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That last point matters more than it looks. If your plans have monthly quotas, "you've used this month's allowance" is often also a 429, and its &lt;code&gt;Retry-After&lt;/code&gt; can be days away. A client that sleeps on every &lt;code&gt;Retry-After&lt;/code&gt; will park a job for a week; one that ignores it and retries with backoff will keep hammering an answer that won't change. A reasonable client rule:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;wait&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;retry-after&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;wait&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Not retrying: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;, retry after &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;wait&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;s`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;wait&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Put the same rule in your API docs, and give the two cases different &lt;code&gt;error&lt;/code&gt; codes so people can tell them apart in their logs.&lt;/p&gt;

&lt;h2&gt;
  
  
  More than one process
&lt;/h2&gt;

&lt;p&gt;Everything above lives in one process's memory. Put four instances behind a load balancer and a customer whose requests spread evenly gets about four times the limit. You have three choices:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Accept it.&lt;/strong&gt; A per-process cap can be enough to curb runaway scripts, as long as you can live with a customer reaching 4× the configured limit. It won't enforce a per-customer limit you've promised in a contract.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Divide the limit by the number of instances&lt;/strong&gt;, rounded up and never below 1. That keeps the total close to what you set without any shared state, but you need a reliable instance count, and a client whose keep-alive connection pins it to one instance gets only that instance's share.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use a shared store such as Redis&lt;/strong&gt;, with the bucket update in a Lua script so it's atomic. That's exact, at the cost of a network round trip per request and a decision about what happens when Redis is down.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Decide which one you're doing before autoscaling decides for you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test it with a fake clock
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;tokenBucket()&lt;/code&gt; takes &lt;code&gt;now&lt;/code&gt; as a parameter so tests don't have to sleep. Pass a function that returns a number you control, then check the edges: exactly &lt;code&gt;capacity&lt;/code&gt; requests pass, the next one fails with &lt;code&gt;retryAfter: 1&lt;/code&gt;, half a token isn't enough, and a long pause refills the bucket to &lt;code&gt;capacity&lt;/code&gt; and no further.&lt;/p&gt;




&lt;p&gt;I work on UsageRail, which does the per-customer part of this as middleware for Express (and FastAPI, Hono, Fastify, Django and Next.js), with the limits set per plan in a dashboard instead of in code: &lt;a href="https://usagerail.com/docs/express" rel="noopener noreferrer"&gt;https://usagerail.com/docs/express&lt;/a&gt;&lt;/p&gt;

</description>
      <category>api</category>
      <category>node</category>
      <category>python</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How long does a Postgres restore actually take?</title>
      <dc:creator>SuperLede</dc:creator>
      <pubDate>Sun, 01 Nov 2026 16:35:45 +0000</pubDate>
      <link>https://dev.to/superlede/how-long-does-a-postgres-restore-actually-take-2le7</link>
      <guid>https://dev.to/superlede/how-long-does-a-postgres-restore-actually-take-2le7</guid>
      <description>&lt;p&gt;When someone asks how long it would take to get the database back, the answer is usually a guess based on the size of the dump. I wanted a real number, so we timed it: one schema at four sizes, from a 400 MB Supabase project up to a 10 GB database with 18.8 million rows, each dump restored into an empty PostgreSQL 17 on a single 2 vCPU / 8 GB VM.&lt;/p&gt;

&lt;p&gt;The 10 GB restore took about 12 minutes. Most of those 12 minutes went to rebuilding indexes and foreign keys. Loading the rows was the smaller part, and that changes how you should estimate your own restore.&lt;/p&gt;

&lt;h2&gt;
  
  
  The numbers
&lt;/h2&gt;

&lt;p&gt;Plain &lt;code&gt;pg_restore&lt;/code&gt; with one job, into a fresh PostgreSQL 17 container:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Database&lt;/th&gt;
&lt;th&gt;Rows&lt;/th&gt;
&lt;th&gt;Dump&lt;/th&gt;
&lt;th&gt;Restore&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;396 MiB (real Supabase Free project)&lt;/td&gt;
&lt;td&gt;723,500&lt;/td&gt;
&lt;td&gt;74.6 MiB&lt;/td&gt;
&lt;td&gt;19.4 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1.03 GiB&lt;/td&gt;
&lt;td&gt;2,172,000&lt;/td&gt;
&lt;td&gt;226.5 MiB&lt;/td&gt;
&lt;td&gt;65.9 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5.04 GiB&lt;/td&gt;
&lt;td&gt;9,222,000&lt;/td&gt;
&lt;td&gt;1.00 GiB&lt;/td&gt;
&lt;td&gt;379.8 s (6.3 min)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10.05 GiB&lt;/td&gt;
&lt;td&gt;18,822,000&lt;/td&gt;
&lt;td&gt;1.74 GiB&lt;/td&gt;
&lt;td&gt;725.9 s (12.1 min)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Sizes are &lt;code&gt;pg_database_size&lt;/code&gt; of the source. The schema is modeled on a multi-tenant SaaS app with an AI feature: orgs, users, projects, orders, an events table with JSONB payloads, a documents table with 384-dimension pgvector embeddings, 16 indexes, 7 RLS policies, triggers and functions. The three bigger databases are synthetic copies of that schema, and most of their size is event rows.&lt;/p&gt;

&lt;p&gt;I also restored every dump twice through the restore drill of BackupDrill, the backup tool I work on. At every size, the restore step of those drills averaged within 5% of the single-job time above. That comparison is the restore alone; a full drill also downloads the dump, starts the database and checks every table.&lt;/p&gt;

&lt;p&gt;Two things to keep in mind before you quote any of this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The target ran with durability turned off&lt;/strong&gt;: &lt;code&gt;fsync&lt;/code&gt;, &lt;code&gt;synchronous_commit&lt;/code&gt; and &lt;code&gt;full_page_writes&lt;/code&gt; off, &lt;code&gt;wal_level=minimal&lt;/code&gt;, &lt;code&gt;shared_buffers&lt;/code&gt; at 1.9 GB and &lt;code&gt;maintenance_work_mem&lt;/code&gt; at 960 MB. That's fine for a test copy you delete afterwards. It's not how you'd run a database you're recovering production into. In a separate run earlier the same day, the 1 GB restore took 61 seconds with these settings and 110 seconds on stock PostgreSQL settings, about 1.8x slower.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;There's no download time in here.&lt;/strong&gt; The dump sat in a bucket on the same VM; the 1.74 GiB dump came down in 15 seconds. If your backup lives in another region, add however long it takes to move the file.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Where the 12 minutes went
&lt;/h2&gt;

&lt;p&gt;The 10 GB restore, one job, timed step by step from &lt;code&gt;pg_restore --verbose&lt;/code&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Step&lt;/th&gt;
&lt;th&gt;Time&lt;/th&gt;
&lt;th&gt;Share&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Build the pgvector HNSW index (200,000 embeddings, 384 dimensions)&lt;/td&gt;
&lt;td&gt;184.8 s&lt;/td&gt;
&lt;td&gt;25%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Build the JSONB GIN index on events&lt;/td&gt;
&lt;td&gt;145.5 s&lt;/td&gt;
&lt;td&gt;20%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Load the events table (13.5 million rows)&lt;/td&gt;
&lt;td&gt;141.3 s&lt;/td&gt;
&lt;td&gt;19%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Add the three foreign keys on events&lt;/td&gt;
&lt;td&gt;102.8 s&lt;/td&gt;
&lt;td&gt;14%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Add the primary key on events&lt;/td&gt;
&lt;td&gt;57.7 s&lt;/td&gt;
&lt;td&gt;8%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Build the (project_id, created_at) index on events&lt;/td&gt;
&lt;td&gt;43.3 s&lt;/td&gt;
&lt;td&gt;6%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Everything else: five smaller tables, their indexes and constraints, RLS policies, triggers&lt;/td&gt;
&lt;td&gt;50.5 s&lt;/td&gt;
&lt;td&gt;7%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Total&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;725.9 s&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;100%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Loading the biggest table, 13.5 million rows, took 141 seconds. One HNSW index over 200,000 vectors took longer than that on its own. Averaged over the two drill restores of this database, 77% of the restore (559 of 722 seconds) went to indexes, constraints and foreign keys, and 163 seconds to loading all 18.8 million rows.&lt;/p&gt;

&lt;p&gt;That follows from what a custom-format dump contains. It has the rows and the definition of each index, not the index itself. &lt;code&gt;pg_database_size&lt;/code&gt; counts index pages; the dump doesn't carry any. Across all four databases the compressed dump came out at 17–22% of the database size, and every index missing from the file gets built from scratch during the restore. Foreign keys get checked again against every row.&lt;/p&gt;

&lt;h2&gt;
  
  
  Estimate from your schema, not your dump size
&lt;/h2&gt;

&lt;p&gt;Two databases with the same dump size can restore at very different speeds. One with a few large tables and a primary key on each is mostly &lt;code&gt;COPY&lt;/code&gt;. One with GIN indexes on JSONB, trigram indexes, a vector index and a dozen foreign keys spends most of its restore in &lt;code&gt;CREATE INDEX&lt;/code&gt; and &lt;code&gt;ALTER TABLE&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can see how much rebuilding is waiting in a dump before you restore anything:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pg_restore &lt;span class="nt"&gt;--list&lt;/span&gt; app.dump | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-cE&lt;/span&gt; &lt;span class="s1"&gt;' INDEX | CONSTRAINT | FK CONSTRAINT '&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A count won't give you minutes, though. For that, time a restore of your own dump in a throwaway container. This one uses the same kind of tuning as our test target:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;--name&lt;/span&gt; restore-test &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;POSTGRES_PASSWORD&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;pw &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-p&lt;/span&gt; 127.0.0.1:5433:5432 &lt;span class="nt"&gt;--shm-size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1g postgres:17 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="nv"&gt;fsync&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;off &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="nv"&gt;synchronous_commit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;off &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="nv"&gt;full_page_writes&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;off &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="nv"&gt;wal_level&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;minimal &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="nv"&gt;max_wal_senders&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="nv"&gt;shared_buffers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;2GB &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="nv"&gt;maintenance_work_mem&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1GB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Scale &lt;code&gt;shared_buffers&lt;/code&gt; and &lt;code&gt;maintenance_work_mem&lt;/code&gt; down on a machine with less memory. &lt;code&gt;--shm-size&lt;/code&gt; matters because parallel index builds, HNSW builds included, use shared memory, and Docker's default 64 MB can be too small for them. &lt;code&gt;wal_level=minimal&lt;/code&gt; only starts with &lt;code&gt;max_wal_senders=0&lt;/code&gt;. If your tables have vector columns, swap &lt;code&gt;postgres:17&lt;/code&gt; for an image that ships pgvector, such as &lt;code&gt;pgvector/pgvector:pg17&lt;/code&gt;, which is what our test used. Our target also had the extensions the schema needed (pg_trgm, pgvector) and Supabase's auth stubs created before the restore.&lt;/p&gt;

&lt;p&gt;Then restore with a timestamp on every line of verbose output:&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="nv"&gt;PGPASSWORD&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;pw pg_restore &lt;span class="nt"&gt;--verbose&lt;/span&gt; &lt;span class="nt"&gt;--no-owner&lt;/span&gt; &lt;span class="nt"&gt;--no-privileges&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-h&lt;/span&gt; 127.0.0.1 &lt;span class="nt"&gt;-p&lt;/span&gt; 5433 &lt;span class="nt"&gt;-U&lt;/span&gt; postgres &lt;span class="nt"&gt;-d&lt;/span&gt; postgres app.dump 2&amp;gt;&amp;amp;1 &lt;span class="se"&gt;\&lt;/span&gt;
  | perl &lt;span class="nt"&gt;-MTime&lt;/span&gt;::HiRes&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;time&lt;/span&gt; &lt;span class="nt"&gt;-ne&lt;/span&gt; &lt;span class="s1"&gt;'printf "%.1f %s", time, $_'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; restore.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And list the slowest steps:&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="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'NR &amp;gt; 1 { printf "%6.1fs  %s\n", $1 - prev_time, prev_line }
     { prev_time = $1; $1 = ""; prev_line = $0 }'&lt;/span&gt; restore.log | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-rn&lt;/span&gt; | &lt;span class="nb"&gt;head&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With a single job, the gap between one line and the next is roughly how long the step on the first line took, so the top of that list is where your restore time goes. Use a &lt;code&gt;pg_restore&lt;/code&gt; of the same major version as the &lt;code&gt;pg_dump&lt;/code&gt; that made the file, or newer. If the dump came from Supabase and the restore complains about the &lt;code&gt;auth&lt;/code&gt; schema, I wrote up &lt;a href="https://dev.to/superlede/pgrestore-finished-fine-one-of-my-tables-wasnt-there-2kaj"&gt;the stubs a plain Postgres target needs&lt;/a&gt; a while ago.&lt;/p&gt;

&lt;h2&gt;
  
  
  What these numbers don't cover
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;More cores.&lt;/strong&gt; Everything here ran on 2 vCPU. &lt;code&gt;pg_restore --jobs&lt;/code&gt; can build several indexes at the same time, so a bigger machine can beat these numbers. We didn't test one.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Restoring into a new Supabase project.&lt;/strong&gt; Speed then depends on the project's compute size and your connection to it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Supabase's own restore&lt;/strong&gt; from daily backups or point-in-time recovery. The Free plan has neither, so we couldn't time it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Other schemas.&lt;/strong&gt; More indexes per gigabyte, bigger vector indexes or thousands of small tables will spend the time differently.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Taking the backup was the quick part, at least for the small database: 25 seconds to dump the 400 MB Supabase Free project through the Session pooler from a VM in the same region (Ashburn to us-east-1), for a 75 MB file.&lt;/p&gt;

&lt;p&gt;The full result tables, the drill timings, the test setup and the list of what we didn't test are on the &lt;a href="https://backupdrill.com/research/postgres-restore-time" rel="noopener noreferrer"&gt;benchmark page&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I work on BackupDrill, which runs scheduled backups and restore drills for Supabase projects. The drill timings above come from its open-source CLI; the plain &lt;code&gt;pg_restore&lt;/code&gt; numbers don't depend on it.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>postgres</category>
      <category>supabase</category>
      <category>database</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
