Posts

My zshell customizations

Mittwoch, 22. März 2023, 09:30 Uhr | roberto@vasquez-angel.de |

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

# place this after nvm initialization!
autoload -U add-zsh-hook
load-nvmrc() {
  local node_version="$(nvm version)"
  local nvmrc_path="$(nvm_find_nvmrc)"

  if [ -n "$nvmrc_path" ]; then
    local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")

    if [ "$nvmrc_node_version" = "N/A" ]; then
      nvm install
    elif [ "$nvmrc_node_version" != "$node_version" ]; then
      nvm use --silent
    fi
  elif [ "$node_version" != "$(nvm version default)" ]; then
    nvm use default --silent
  fi
}
add-zsh-hook chpwd load-nvmrc
load-nvmrc

# publish gems the easy way
function publish_gem {
    TMP=$(gem build $(ls *.gemspec));
    GEM_NAME=$(echo $TMP |& tail -1 | sed -r 's/.*File: //g');
    echo Publishing ${GEM_NAME};
    gem push $GEM_NAME;
}

# Dokku client
alias dokku='$HOME/.dokku/contrib/dokku_client.sh'

# SSH keychain
eval `keychain --quiet --eval --agents ssh id_rsa`

How to restore an encrypted dokku postgres dump to your local dev environment

Dienstag, 07. März 2023, 16:23 Uhr | roberto@vasquez-angel.de |

Go to the s3 storage, locate the dump and download it. Let’s assume the file is called dump.tgz.gpg

Decrypt the dump using the passphrase/key you have safely stored (i.e. in a password manager):

#> gpg --pinentry-mode=loopback --passphrase "<passphrase>" -d -o dump.tgz dump.tgz.gpg

Create a directory as unpacking target:

#> mkdir dump

Unpack the dump:

#> tar zxvf dump.tgz -C dump

Drop the current database and recreate it, so it is empty. If you are using rails you can use following commands:

#> rails db:drop && rails db:create

Restore the dump to your local postgres database:

#> pg_restore -U <username> -d <database_name> --no-owner < dump/backup/export