<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.3.4">Jekyll</generator><link href="https://kklisura.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://kklisura.com/" rel="alternate" type="text/html" /><updated>2026-01-04T17:27:42+00:00</updated><id>https://kklisura.com/feed.xml</id><title type="html">Kenan Klisura’s Blog</title><subtitle>A exploration of software, life, and everything in between.</subtitle><entry><title type="html">Postgres Interactive Restore</title><link href="https://kklisura.com/2023/10/27/postgres-interactive-restore.html" rel="alternate" type="text/html" title="Postgres Interactive Restore" /><published>2023-10-27T00:00:00+00:00</published><updated>2023-10-27T00:00:00+00:00</updated><id>https://kklisura.com/2023/10/27/postgres-interactive-restore</id><content type="html" xml:base="https://kklisura.com/2023/10/27/postgres-interactive-restore.html"><![CDATA[<p>If you have used git interactive rebase, you know you can specify how rebase is done by picking specific commits, skipping, editing, etc. by merely editing a file in editor (most likely vim). Well <code class="language-plaintext highlighter-rouge">pg_restore</code> has <em>similar</em> feature.</p>

<p><em>git rebase -i HEAD~3</em> <sup id="fnref:1" role="doc-noteref"><a href="#fn:1" class="footnote" rel="footnote">1</a></sup></p>
<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>pick f7f3f6d Change my name a bit
pick 310154e Update README formatting and add blame
pick a5f4a0d Add cat-file

# Rebase 710f0f8..a5f4a0d onto 710f0f8
#
# Commands:
# p, pick &lt;commit&gt; = use commit
# r, reword &lt;commit&gt; = use commit, but edit the commit message
# e, edit &lt;commit&gt; = use commit, but stop for amending
# s, squash &lt;commit&gt; = use commit, but meld into previous commit
# f, fixup &lt;commit&gt; = like "squash", but discard this commit's log message
# x, exec &lt;command&gt; = run command (the rest of the line) using shell
# b, break = stop here (continue rebase later with 'git rebase --continue')
# d, drop &lt;commit&gt; = remove commit
# l, label &lt;label&gt; = label current HEAD with a name
# t, reset &lt;label&gt; = reset HEAD to a label
# m, merge [-C &lt;commit&gt; | -c &lt;commit&gt;] &lt;label&gt; [# &lt;oneline&gt;]
# .       create a merge commit using the original merge commit's
# .       message (or the oneline, if no original merge commit was
# .       specified). Use -c &lt;commit&gt; to reword the commit message.
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out
</code></pre></div></div>

<p>I had a PG DB dump just the other day and I needed to apply it to my database, but I need to apply only specific changes (tables, constraints, functions, etc). I’ve had that before and I’ve used <code class="language-plaintext highlighter-rouge">--table</code>, <code class="language-plaintext highlighter-rouge">--schema</code> or <code class="language-plaintext highlighter-rouge">--trigger</code> where you can specify by name what you want to restore. I’ve now discovered that <code class="language-plaintext highlighter-rouge">pg_restore</code> has better option, an <em>interactive</em> option similar to git interactive rebase.</p>

<p>By specifying <code class="language-plaintext highlighter-rouge">--list</code> argument for <code class="language-plaintext highlighter-rouge">pg_restore</code> <sup id="fnref:2" role="doc-noteref"><a href="#fn:2" class="footnote" rel="footnote">2</a></sup>, a file gets created instead of restoring database. That file contains a list of actions to be performed during restore. An example file:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>;
; Archive created at Mon Sep 14 13:55:39 2009
;     dbname: DBDEMOS
;     TOC Entries: 81
;     Compression: 9
;     Dump Version: 1.10-0
;     Format: CUSTOM
;     Integer: 4 bytes
;     Offset: 8 bytes
;     Dumped from database version: 8.3.5
;     Dumped by pg_dump version: 8.3.8
;
;
; Selected TOC Entries:
;
3; 2615 2200 SCHEMA - public demouser
1861; 0 0 COMMENT - SCHEMA public demouser
41; 2615 2200 SCHEMA - event_store demouser
64; 0 0 COMMENT - SCHEMA event_store demouser
238; 1259 17443 TABLE event_store events demouser
;	depends on: 41
286; 1255 17473 FUNCTION event_store event_store_delete() demouser
;	depends on: 41
242; 1259 17492 TABLE event_store snapshots demouser
;	depends on: 41
...
</code></pre></div></div>

<p>The file represents just list of internal IDs of object to be restored and everything after <code class="language-plaintext highlighter-rouge">;</code> is a comment. So essentially the file content above is just:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>3
1861
41
64
238
286
242
</code></pre></div></div>

<p>By editing the file above to just:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>238; 1259 17443 TABLE event_store events demouser
;	depends on: 41
286; 1255 17473 FUNCTION event_store event_store_delete() demouser
;	depends on: 41
242; 1259 17492 TABLE event_store snapshots demouser
;	depends on: 41
</code></pre></div></div>

<p>…and by using <code class="language-plaintext highlighter-rouge">--use-list</code> with the file path on next <code class="language-plaintext highlighter-rouge">pg_restore</code> command, you can restore just the items specified in the file! So in this case it’s just <code class="language-plaintext highlighter-rouge">events</code> and <code class="language-plaintext highlighter-rouge">snapshots</code> table on <code class="language-plaintext highlighter-rouge">event_store</code> schema together with <code class="language-plaintext highlighter-rouge">event_store_delete</code> function.</p>

<p>In summary:</p>

<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># Generate list of entries - entries.txt</span>
pg_restore <span class="nt">--list</span> <span class="nt">--verbose</span> <span class="nt">-h</span> localhost <span class="nt">-U</span> postgres <span class="nt">-d</span> test_db pg_db_dump.tar.gz <span class="o">&gt;</span> entries.txt

<span class="c"># Edit the entries.txt</span>

<span class="c"># Apply the entries</span>
pg_restore <span class="nt">--verbose</span> <span class="nt">-h</span> localhost <span class="nt">-U</span> postgres <span class="nt">-d</span> test_db pg_db_dump.tar.gz <span class="nt">--use-list</span> entries.txt
</code></pre></div></div>

<h2 id="references">References</h2>

<div class="footnotes" role="doc-endnotes">
  <ol>
    <li id="fn:1" role="doc-endnote">
      <p><a href="https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History">https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History</a> <a href="#fnref:1" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:2" role="doc-endnote">
      <p><a href="https://www.postgresql.org/docs/current/app-pgrestore.html">https://www.postgresql.org/docs/current/app-pgrestore.html</a> <a href="#fnref:2" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
  </ol>
</div>]]></content><author><name></name></author><category term="postgres" /><summary type="html"><![CDATA[If you have used git interactive rebase, you know you can specify how rebase is done by picking specific commits, skipping, editing, etc. by merely editing a file in editor (most likely vim). Well pg_restore has similar feature.]]></summary></entry><entry><title type="html">NASA’s Mars helicopter - Ingenuity: research materials</title><link href="https://kklisura.com/2022/04/11/nasas-mars-helicopter-ingenuity-research-materials.html" rel="alternate" type="text/html" title="NASA’s Mars helicopter - Ingenuity: research materials" /><published>2022-04-11T00:00:00+00:00</published><updated>2022-04-11T00:00:00+00:00</updated><id>https://kklisura.com/2022/04/11/nasas-mars-helicopter---ingenuity-research-materials</id><content type="html" xml:base="https://kklisura.com/2022/04/11/nasas-mars-helicopter-ingenuity-research-materials.html"><![CDATA[<p>I was reading a lot about <a href="https://en.wikipedia.org/wiki/Ingenuity_(helicopter)">NASA’s Mars helicopter - Ingenuity</a>, so I’ve compiled a list of links: materials and research papers about it. I’m mostly interested in hardware and software - especially in terms on navigation. All of the materials are easily obtained by googling them, so that’s the reason I’m including links to them as well.</p>

<p>Since the Ingenuity uses COTS (Commerical Off-the-shelf) components, some of the navigation features could, in theory, be implemented using a smart phone ie using IMU and using camera as vision input for building a navigation demonstrator.</p>

<p><a href="https://picknik.ai/slam/localization/state%20estimation/mars%20helicopter/2021/05/10/Ingenuity.html">How Ingenuity Knows Where It Is And Where It’s Going</a> (article, blog post)</p>

<p><a href="https://rotorcraft.arc.nasa.gov/Publications/files/Balaram_AIAA2018_0023.pdf">Mars Helicopter Technology Demonstrator</a> (NASA, research paper)</p>

<p><a href="https://insideunmannedsystems.com/inside-the-ingenuity-helicopter-teamwork-on-mars/">Inside the Ingenuity Helicopter: Teamwork on Mars</a> (article, blog post)</p>

<p><a href="https://dartslab.jpl.nasa.gov/References/pdf/2019-mars-heli.pdf">Flight Control System for NASA’s Mars Helicopter</a> (NASA, research paper)</p>

<p><a href="https://rotorcraft.arc.nasa.gov/Publications/files/Grip_AIAA2018_1849.pdf">Guidance and Control for a Mars Helicopter</a> (NASA, research paper)</p>

<p><a href="https://arc.aiaa.org/doi/abs/10.2514/6.2019-1411">Vision-Based Navigation for the NASA Mars Helicopter</a> (research paper)</p>

<p><a href="https://trs.jpl.nasa.gov/bitstream/handle/2014/46668/CL%2317-2410.pdf?sequence=1">A minimal state augmentation algorithm for vision-based navigation without using mapped landmarks</a> (NASA, research paper)</p>

<p><a href="https://rotorcraft.arc.nasa.gov/Publications/files/Koning_2018_TechMx.pdf">Generation of Mars Helicopter Rotor Model for Comprehensive Analyses</a> (NASA, research paper)</p>

<p><a href="https://ethz.ch/content/dam/ethz/special-interest/mavt/robotics-n-intelligent-systems/asl-dam/documents/news/weiss12realtime.pdf">Real-time Onboard Visual-Inertial State Estimation and Self-Calibration of MAVs in Unknown Environments</a> (research paper)</p>]]></content><author><name></name></author><category term="NASA" /><category term="ingenuity" /><category term="vision system" /><category term="navigation" /><summary type="html"><![CDATA[I was reading a lot about NASA’s Mars helicopter - Ingenuity, so I’ve compiled a list of links: materials and research papers about it. I’m mostly interested in hardware and software - especially in terms on navigation. All of the materials are easily obtained by googling them, so that’s the reason I’m including links to them as well.]]></summary></entry></feed>