<?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: Helder Rossa</title>
    <description>The latest articles on DEV Community by Helder Rossa (@kimus).</description>
    <link>https://dev.to/kimus</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1035842%2Fb97f85f0-4118-4e05-8690-ca03f3635a51.jpeg</url>
      <title>DEV Community: Helder Rossa</title>
      <link>https://dev.to/kimus</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kimus"/>
    <language>en</language>
    <item>
      <title>rust api</title>
      <dc:creator>Helder Rossa</dc:creator>
      <pubDate>Fri, 18 Jul 2025 16:35:38 +0000</pubDate>
      <link>https://dev.to/kimus/rust-api-2eka</link>
      <guid>https://dev.to/kimus/rust-api-2eka</guid>
      <description></description>
      <category>rust</category>
      <category>api</category>
      <category>backenddevelopment</category>
    </item>
    <item>
      <title>How easy and securely is to backup your computer?</title>
      <dc:creator>Helder Rossa</dc:creator>
      <pubDate>Sun, 12 Mar 2023 12:09:19 +0000</pubDate>
      <link>https://dev.to/kimus/how-easy-and-securely-is-to-backup-your-computer-2g7d</link>
      <guid>https://dev.to/kimus/how-easy-and-securely-is-to-backup-your-computer-2g7d</guid>
      <description>&lt;p&gt;We all know that we should always back up our stuff and that there's lots of things that can go wrong if we don't:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Hard drives could fail or loss data&lt;/li&gt;
&lt;li&gt;  Files of folders can accidentally be deleted, become corrupt, or maybe accidentally over wrote a newer one&lt;/li&gt;
&lt;li&gt;  Viruses can corrupt or delete files&lt;/li&gt;
&lt;li&gt;  You may upgrade to a new computer and need to move your files.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For what ever reason, and depending on the importance of that information, you could be in a seriously problem or loose hours of work.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://restic.net/"&gt;Restic&lt;/a&gt;  is the backup software that I'm using to backup my files. Its Open Source, with strong encryption, versioning, and only transfers what you need to, so you don't use up more space than you need to. Works on Linux, Mac, BSD, and Windows, however if you want to use Restic, you still need to know your way around a shell.&lt;/p&gt;

&lt;p&gt;This is one of the tools that I use to &lt;a href="https://dev.to/kimus/my-macos-from-scratch-setup-6ja"&gt;restore my computer from scratch&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Restic Setup
&lt;/h2&gt;

&lt;p&gt;Let's create the restic configuration folders (you can create on any other path, this is just my preference):&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;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; ~/.restic/backups
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And create the &lt;code&gt;~/.restic/cron.sh&lt;/code&gt; script to perform the backups:&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;#!/usr/bin/env zsh&lt;/span&gt;
&lt;span class="nv"&gt;RESTIC_ROOT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt; &lt;span class="nb"&gt;cd&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;dirname&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$0&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;pwd&lt;/span&gt; &lt;span class="nt"&gt;-P&lt;/span&gt; &lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

&lt;span class="k"&gt;for &lt;/span&gt;BACKUP_ROOT &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;$RESTIC_ROOT&lt;/span&gt;/backups/&lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
    &lt;/span&gt;&lt;span class="nb"&gt;source&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$BACKUP_ROOT&lt;/span&gt;&lt;span class="s2"&gt;/env"&lt;/span&gt;

    &lt;span class="nv"&gt;BACKUP_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$BACKUP_ROOT&lt;/span&gt;&lt;span class="s2"&gt;/path"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;

    restic backup &lt;span class="nv"&gt;$BACKUP_DIR&lt;/span&gt; &lt;span class="nt"&gt;-q&lt;/span&gt; &lt;span class="nt"&gt;--exclude-file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$BACKUP_ROOT&lt;/span&gt;&lt;span class="s2"&gt;/excludes"&lt;/span&gt; &lt;span class="nt"&gt;--exclude-caches&lt;/span&gt;

    restic forget &lt;span class="nt"&gt;-q&lt;/span&gt; &lt;span class="nt"&gt;--keep-last&lt;/span&gt; 2 &lt;span class="nt"&gt;--prune&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This script will go throw all backup configurations and perform the backup and forget restic commands for each of them.&lt;/p&gt;

&lt;p&gt;Note that I'm keeping the last two backups, but there's a lot of options in restic. You can choose to keep weekly, monthly or yearly backups. Just go to their documentation about &lt;a href="https://restic.readthedocs.io/en/stable/060_forget.html#removing-snapshots-according-to-a-policy"&gt;keep policy&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Backup configuration
&lt;/h2&gt;

&lt;p&gt;So, let's create our first backup configuration. In this case, I'll backup stuff from my user home folder.&lt;/p&gt;

&lt;p&gt;Instead of resting prompting for the password, and manually creating one, I prefer to generate a random password. And so, using &lt;code&gt;openssl&lt;/code&gt; to generate a bunch or random characters:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;openssl rand &lt;span class="nt"&gt;-hex&lt;/span&gt; 64 &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; ~/.restic/backups/home/password
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Remembering your password is important! If you lose it, you won’t be able to access data stored in the repository because all data it's encrypted.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;After that, store my home folder path:&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;echo&lt;/span&gt; &lt;span class="nv"&gt;$HOME&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; ~/.restic/backups/home/path
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set &lt;a href="https://restic.readthedocs.io/en/stable/040_backup.html#environment-variables"&gt;environment configurations&lt;/a&gt; for this backup. I'm using &lt;a href="https://www.backblaze.com/b2/cloud-storage.html"&gt;B2 Cloud Storage&lt;/a&gt; for this. It's free for the first 10 GB. You can use any of the restic &lt;a href="https://restic.readthedocs.io/en/stable/030_preparing_a_new_repo.html"&gt;supported repositories&lt;/a&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="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; ~/.restic/backups/home/env &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;EOL&lt;/span&gt;&lt;span class="sh"&gt;
export RESTIC_REPOSITORY=b2:bucket-name:path-to-store
export B2_ACCOUNT_ID=&amp;lt;your account id here&amp;gt;
export B2_ACCOUNT_KEY=&amp;lt;your account key here&amp;gt;
export RESTIC_PASSWORD_FILE=~/.restic/backups/home/password
&lt;/span&gt;&lt;span class="no"&gt;EOL
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create the &lt;a href="https://restic.readthedocs.io/en/stable/040_backup.html#excluding-files"&gt;excludes&lt;/a&gt; file. In reality this is where I say restic what to backup in every line starting with the &lt;code&gt;!&lt;/code&gt; sign:&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;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; ~/.restic/backups/home/excludes &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;EOL&lt;/span&gt;&lt;span class="sh"&gt;
# excluding any directory, then selectively add back some of them
/Users/kimus/*
!/Users/kimus/Documents
!/Users/kimus/Develop
/Users/kimus/Develop/**/*.gz

# dotfiles
!/Users/kimus/.local/share/chezmoi
!/Users/kimus/.gitconfig
!/Users/kimus/.restic
!/Users/kimus/.ssh
!/Users/kimus/.zshrc
!/Users/kimus/.zprofile
!/Users/kimus/.kube
/Users/kimus/.kube/cache

# global ignores
node_modules
.next/cache
.DS_Store
&lt;/span&gt;&lt;span class="no"&gt;EOL
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Please note that this is my initial configuration, and yours could be different. You should take some time to make sure your are backing up all information that you need and excluding files that you don't. Doing so, the backup will be optimised in size and that will provide faster backup times and less payments in your cloud provider.&lt;/p&gt;

&lt;p&gt;In the end will get something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;.restic
├── backups
│   └── home
│       ├── &lt;span class="nb"&gt;env&lt;/span&gt;
│       ├── excludes
│       ├── password
│       └── path
└── cron.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In my case I'm trying to backup only the essencial files, like the dotfiles, source code, documents, etc. All files or folders not needed I will exclude them. And so, to test the configuration, and check all the files this configuration will backup you can use the following:&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;source&lt;/span&gt; ~/.restic/backups/user/env
restic backup &lt;span class="nv"&gt;$HOME&lt;/span&gt; &lt;span class="nt"&gt;--exclude-file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/.restic/backups/home/excludes"&lt;/span&gt; &lt;span class="nt"&gt;--dry-run&lt;/span&gt; &lt;span class="nt"&gt;-vv&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;check for files bigger then a size:&lt;br&gt;
&lt;code&gt;du -ch -t 1M Develop | grep -v node_modules&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Manually execute the &lt;code&gt;cron.sh&lt;/code&gt; and you will get your first backup. To check, you can execute the &lt;code&gt;snapshots&lt;/code&gt; command. You will need the source the env file if not done yet.&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;source&lt;/span&gt; ~/.restic/backups/user/env
&lt;span class="nv"&gt;$ &lt;/span&gt;restic snapshots
repository b4fadbba opened &lt;span class="o"&gt;(&lt;/span&gt;version 2, compression level auto&lt;span class="o"&gt;)&lt;/span&gt;
ID        Time                 Host                   Tags        Paths
&lt;span class="nt"&gt;------------------------------------------------------------------------------&lt;/span&gt;
e4183d6f  2023-03-10 12:00:00  Helders-MacBook-Pro14              /Users/kimus
&lt;span class="nt"&gt;------------------------------------------------------------------------------&lt;/span&gt;
1 snapshot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And to check the size of the snapshot, and other ifnormation you could use the &lt;code&gt;stats&lt;/code&gt; command. I use this to check and control the size of the backup information:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;❯ restic stats latest
repository b4fadbba opened &lt;span class="o"&gt;(&lt;/span&gt;version 2, compression level auto&lt;span class="o"&gt;)&lt;/span&gt;
scanning...
Stats &lt;span class="k"&gt;in &lt;/span&gt;restore-size mode:
     Snapshots processed:  1
        Total File Count:  8097
              Total Size:  758.753 MiB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Schedule Backups
&lt;/h2&gt;

&lt;p&gt;If you wonder how often you should back up your data, just ask yourself, "&lt;em&gt;How many days work can I afford to lose&lt;/em&gt;"? Whenever you make changes to files, or add new files, you need to back up your files again. It is a good practice to back up your files on a daily basis. If you are working on a critical project, you may want to back it up even more often.&lt;/p&gt;

&lt;p&gt;For simplicity I'm using crontab to do scheduled backups every day at 12h.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0 12 * * * source $HOME/.zprofile; /Users/kimus/.restic/cron.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;I'm including my &lt;code&gt;~/.zprofile&lt;/code&gt; because I use &lt;code&gt;zsh&lt;/code&gt; and it's where I'm loading my &lt;code&gt;homebrew&lt;/code&gt; configuration. Depending on your enviorment configuration you can just put the &lt;code&gt;cron.sh&lt;/code&gt; here.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Restoring from backup
&lt;/h2&gt;

&lt;p&gt;Restoring a snapshot is as easy as it sounds, just use the following command to restore the contents of the &lt;code&gt;latest&lt;/code&gt; snapshot to &lt;code&gt;/tmp/restore-work&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="nv"&gt;$ &lt;/span&gt;restic restore latest  &lt;span class="nt"&gt;--target&lt;/span&gt; /tmp/restore-work
repository b4fadbba opened &lt;span class="o"&gt;(&lt;/span&gt;version 2, compression level auto&lt;span class="o"&gt;)&lt;/span&gt;
restoring &amp;lt;Snapshot 5eb3c41e of &lt;span class="o"&gt;[&lt;/span&gt;/Users/kimus] at 2023-03-10 13:54:00.623059 +0000 UTC by kimus@Helders-MacBook-Pro14&amp;gt; to /tmp/restore-work
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;You can use &lt;code&gt;--target=/&lt;/code&gt; to restore the backup to the original path.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Just look at the files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;open /tmp/restore-work
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3759MA3L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ylbo3u39x81toy2cekxh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3759MA3L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ylbo3u39x81toy2cekxh.png" alt="Image of my restored files" width="880" height="497"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;To toggle hidden files in the macOS Finder you can to use &lt;code&gt;Shift+Command+.&lt;/code&gt; shortcut.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Find, Dump or Restore single files
&lt;/h2&gt;

&lt;p&gt;Let's say we want to find the a file &lt;code&gt;cron.sh&lt;/code&gt; from the list of backup snapshots:&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;$ &lt;/span&gt;restic find cron.sh
repository b4fadbba opened &lt;span class="o"&gt;(&lt;/span&gt;version 2, compression level auto&lt;span class="o"&gt;)&lt;/span&gt;
Found matching entries &lt;span class="k"&gt;in &lt;/span&gt;snapshot 3241c91f from 2023-03-12 12:00:00
/Users/kimus/.restic/cron.sh

Found matching entries &lt;span class="k"&gt;in &lt;/span&gt;snapshot 5eb3c41e from 2023-03-10 13:54:00
/Users/kimus/.restic/cron.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we can check the contents of the file by using:&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;$ &lt;/span&gt;restic dump &lt;span class="nt"&gt;-q&lt;/span&gt; 5eb3c41e /Users/kimus/.restic/cron.sh
&lt;span class="c"&gt;#!/usr/bin/env zsh&lt;/span&gt;
&lt;span class="nv"&gt;RESTIC_ROOT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt; &lt;span class="nb"&gt;cd&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;dirname&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$0&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;pwd&lt;/span&gt; &lt;span class="nt"&gt;-P&lt;/span&gt; &lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
   &lt;span class="o"&gt;(&lt;/span&gt;...&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To restore the file we could do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;restic restore latest &lt;span class="nt"&gt;--path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/Users/kimus &lt;span class="nt"&gt;--include&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/Users/kimus/.restic/cron.sh &lt;span class="nt"&gt;--target&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/tmp/restore-work

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Again, you can use &lt;code&gt;--target=/&lt;/code&gt; to restore the file to the original path.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Backup Databases
&lt;/h2&gt;

&lt;p&gt;Regarding database (or any other) dump files we could use the power of restic to backup, versioning and restoring this files. Restic is capable of reading data from stdin, which can be used for saving the output of your database dump program.&lt;/p&gt;

&lt;p&gt;Example of using &lt;code&gt;mongodump&lt;/code&gt; (equivalent to &lt;code&gt;mysqldump&lt;/code&gt;) to backup the dump file to the repository:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mongodump &lt;span class="nt"&gt;-d&lt;/span&gt; database &lt;span class="nt"&gt;--collection&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;Events &lt;span class="nt"&gt;--quiet&lt;/span&gt; &lt;span class="nt"&gt;--gzip&lt;/span&gt; &lt;span class="nt"&gt;--archive&lt;/span&gt; | restic backup &lt;span class="nt"&gt;--stdin&lt;/span&gt; &lt;span class="nt"&gt;--stdin-filename&lt;/span&gt; database-events.tgz
repository b4fadbba opened &lt;span class="o"&gt;(&lt;/span&gt;version 2, compression level auto&lt;span class="o"&gt;)&lt;/span&gt;

Files:           1 new,     0 changed,     0 unmodified
Dirs:            0 new,     0 changed,     0 unmodified
Added to the repository: 291 B &lt;span class="o"&gt;(&lt;/span&gt;262 B stored&lt;span class="o"&gt;)&lt;/span&gt;

processed 1 files, 610 B &lt;span class="k"&gt;in &lt;/span&gt;0:07
snapshot 529265dd saved
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The backup snapshot can now be checked:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;restic snapshots &lt;span class="nt"&gt;--path&lt;/span&gt; /database-events.tgz
repository b4fadbba opened &lt;span class="o"&gt;(&lt;/span&gt;version 2, compression level auto&lt;span class="o"&gt;)&lt;/span&gt;
ID        Time                 Host                   Tags        Paths
&lt;span class="nt"&gt;--------------------------------------------------------------------------------------&lt;/span&gt;
ad104c68  2023-03-12 15:02:47  Helders-MacBook-Pro14              /database-events.tgz
&lt;span class="nt"&gt;--------------------------------------------------------------------------------------&lt;/span&gt;
1 snapshots
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When needed, we could also easily restore it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;restic dump latest database-events.tgz | mongorestore &lt;span class="nt"&gt;--gzip&lt;/span&gt; &lt;span class="nt"&gt;--archive&lt;/span&gt; &lt;span class="nt"&gt;--drop&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>tutorial</category>
      <category>backup</category>
    </item>
    <item>
      <title>My macOS from Scratch for Development</title>
      <dc:creator>Helder Rossa</dc:creator>
      <pubDate>Tue, 28 Feb 2023 19:43:04 +0000</pubDate>
      <link>https://dev.to/kimus/my-macos-from-scratch-setup-6ja</link>
      <guid>https://dev.to/kimus/my-macos-from-scratch-setup-6ja</guid>
      <description>&lt;p&gt;Lately I needed to change computer. I've been thinking about backing up only my relevant files, like documents, images app settings, dotfiles, etc, instead of backing up the full OS. And when I wanted to install my macOS from scratch I would only need to execute a script to restore those files and quickly having a working computer in a couple of minutes.&lt;/p&gt;

&lt;p&gt;Be advice that this is a working progress and I'm open for comments to improve this scripts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start from Scratch
&lt;/h2&gt;

&lt;p&gt;Although not needed to execute the script, you may want to start from scratch (clean your current disk), and if you didn't both a new computer, your only option is to reinstall your macOS. You can read the &lt;a href="https://support.apple.com/en-us/HT204904"&gt;official apple guide&lt;/a&gt; on how to do it.&lt;/p&gt;

&lt;p&gt;But in short:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Restart machine and press &lt;code&gt;Cmd+R&lt;/code&gt; to go into recovery mode&lt;/li&gt;
&lt;li&gt;Open Disk Utility to wipe out disk entirely (this should be an option of the initial setup)&lt;/li&gt;
&lt;li&gt;Quit Disk Utility, go back to setup and use the option to reinstall OS&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now that you have a clean disk you can go through all the steps of installing your macOS, creating the user account, etc.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--u1tgE8QM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dwbim9tu2dvtf32lffva.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--u1tgE8QM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dwbim9tu2dvtf32lffva.png" alt="Image description" width="880" height="572"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Magic Steps
&lt;/h2&gt;

&lt;p&gt;When you gain access to the desktop, you could now follow the next steps that will installs and configure most of the software I use on my personal macOS using &lt;a href="https://brew.sh"&gt;Homebrew&lt;/a&gt; and &lt;a href="https://www.chezmoi.io"&gt;Chezmoi&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Install Homebrew
&lt;/h3&gt;

&lt;p&gt;You need to start from somewhere right? So, let's ensure Homebrew installed using &lt;a href="https://docs.brew.sh/Installation#skip-tap-cloning-beta"&gt;skip tap clonning&lt;/a&gt; option:&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;export &lt;/span&gt;&lt;span class="nv"&gt;HOMEBREW_INSTALL_FROM_API&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;HOMEBREW_NO_ANALYTICS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1
/bin/bash &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://raw.githubusercontent.com/Homebrew/install/master/install.sh&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This also will install Command Line Tools for Xcode, and all the tools for the next steps.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Clone the repository to your local drive
&lt;/h3&gt;

&lt;p&gt;Of course I will use my own repository, but you could clone it and customise it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/kimus/macos-from-scratch
&lt;span class="nb"&gt;cd &lt;/span&gt;macos-from-scratch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Run bootstrap.sh script
&lt;/h3&gt;

&lt;p&gt;From here it's expected to be all automatically.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./bootstrap.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By default it uses your current user name (environment variable USER) to get your dotfiles from GitHub. You can use my own like this:&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;GITHUB_USERNAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;kimus ./bootstrap.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The script will ask you for your &lt;a href="https://bitwarden.com/"&gt;Bitwarden&lt;/a&gt; account. This is where I store my secrets (i.e. SSH keys).&lt;/p&gt;

&lt;p&gt;In the future I'm planning to restore my working folder and other files (pictures, documents, etc) from a backup made with &lt;a href="https://restic.net/"&gt;restic&lt;/a&gt;. I have a separated post about &lt;a href="https://dev.to/kimus/how-easy-and-securely-is-to-backup-your-computer-2g7d"&gt;restic backups&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And that's it, at this time you should have a working macOS with your favourite applications and settings.&lt;/p&gt;

&lt;p&gt;Here is how my terminal looks like:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ces2MffO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0gxbeim5ma0ehqlbmee4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ces2MffO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0gxbeim5ma0ehqlbmee4.png" alt="Image description" width="880" height="531"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Defaults
&lt;/h2&gt;

&lt;p&gt;This script will setup a bunch of tools, applications and configurations.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tools and Applications
&lt;/h3&gt;

&lt;p&gt;Applications (installed with Homebrew Cask):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.docker.com/"&gt;Docker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.google.com/chrome/"&gt;Google Chrome&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.google.com/chrome/dev/"&gt;Google Chrome Dev&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://slack.com/"&gt;Slack&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://code.visualstudio.com/"&gt;Visual Studio Code&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://fork.dev/"&gt;Fork&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://iterm2.com/"&gt;iTerm2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ohmyz.sh"&gt;Oh My Zsh&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://obsidian.md/"&gt;Obsidian&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Check &lt;code&gt;Brewfile&lt;/code&gt; for the full list of tools and applications.&lt;/p&gt;

&lt;h3&gt;
  
  
  Visual Studio Code Extensions
&lt;/h3&gt;

&lt;p&gt;Check &lt;code&gt;vscodefile&lt;/code&gt; for the full list of Visual Studio Code extensions.&lt;/p&gt;

&lt;h3&gt;
  
  
  MacOS System Preferences
&lt;/h3&gt;

&lt;p&gt;There are a few other preferences and settings added on for various apps and services. Check &lt;code&gt;osxfile&lt;/code&gt; for a list of macos specific system preferences.&lt;/p&gt;

&lt;h3&gt;
  
  
  dotfiles
&lt;/h3&gt;

&lt;p&gt;Finally, the &lt;a href="https://github.com/kimus/dotfiles"&gt;dotfiles&lt;/a&gt; are also installed by &lt;code&gt;Chezmoi&lt;/code&gt; into the current user's home directory. This step needs the &lt;code&gt;Bitwarden&lt;/code&gt; account to restore the SSH keys.&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>backup</category>
      <category>macos</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
