Sergey Chulanov
My notes to remember

Put file in a folder on NextCloud

  • Go to NextCloud, open Settings -> Security -> fill “App name” -> click “Create new app password”, so we got login and pass.

  • Create folder in your NextCloud.

  • Fill varables with your own values:

      NEXTCLOUD_USER=your-username
      NEXTCLOUD_PASSWORD=your-app-password
      NEXTCLOUD_FOLDER=gitlab-backups
      PATH_TO_BACKUP=gitlab-backups
      BACKUP_NAME=1691665722_2023_08_10_14.9.2_gitlab_backup.tar
      NEXT_CLOUD_URL=https://your.cloud.tld
  • Run the script:

    
      curl --fail --show-error -u "$NEXTCLOUD_USER:$NEXTCLOUD_PASSWORD" -T "$PATH_TO_BACKUP/$BACKUP_NAME" "$NEXT_CLOUD_URL/remote.php/webdav/$NEXTCLOUD_FOLDER/$BACKUP_NAME"

Install, backup and restore Neo4j database

Tested on: Ubuntu 22.04

Before install you have to check your OpenJDK version, for example for neo4j 5.8.0 you should have openjdk 17.0.7 2023-04-18.

Installation:

Some article who helps install it.

Get gpg.key and add neo4j repository:

curl -fsSL https://debian.neo4j.com/neotechnology.gpg.key | sudo gpg --dearmor -o /usr/share/keyrings/neo4j.gpg
echo "deb [signed-by=/usr/share/keyrings/neo4j.gpg] https://debian.neo4j.com stable latest" | sudo tee -a /etc/apt/sources.list.d/neo4j.list
sudo apt update

Install needed java version:

Back up and restore with MongoDB tools

Tested on: Ubuntu 22.04

MongoDB backup methods from official documentation:

Let’s consider back up with mongodump! Run docker containers with MongoDB on board and a container for our activities with this docker-compose.yml:

Import and export MongoDB collections

Tested on: Ubuntu 22.04

Prepare a mongo server instance:

docker run --rm --name mongo -d mongo:6
docker exec -it -w /root mongo bash
apt update && apt -y install curl less jq

We are in the container, so all command will run from root!

Import

MongoDB is one of the most popular NoSQL database engines. For our test we can take the most popularsample MongoDB database about restaurants:

How to use ssh and scp in Windows

| Windows Server 2019

Run Powershell as an administator and generate private and public keys

ssh-keygen -trsa -b2048

Check that files exists

ls $env:USERPROFILE\.ssh

Add public key

type $env:USERPROFILE\.ssh\id_rsa.pub | ssh root@192.168.131.10 "cat >> .ssh/authorized_keys"

Check connect without password

ssh root@192.168.131.10

Check that commands are runned

ssh root@192.168.131.10 "cat /etc/*release"

Put the file into /tmp

scp "$env:USERPROFILE\.ssh\id_rsa.pub" "root@192.168.131.10:/tmp/"

Put several files into /tmp

scp -r "C:\tmp" "root@192.168.131.10:/tmp/123"
ssh root@192.168.131.10 "ls /tmp/123/tmp"
scp -r "root@192.168.131.10:/tmp/" "C:\tmp"

Run Windows bin as a service

Tested on: Windows

  • Download zss-file nssm from http://nssm.cc/download, unpack it into C:\nssm
  • Run C:\nssm\win64\nssm.exe and choose, any binary, for example traefik.exe
  • Open these ports in windows firewall

Powershell commands for widnows firewall

New-NetFirewallRule -Name 'tcp80' -DisplayName 'tcp80' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 80
New-NetFirewallRule -Name 'tcp443' -DisplayName 'tcp443' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 443

Get-NetFirewallRule -DisplayName tcp80
Get-NetFirewallRule -Name tcp80
Get-NetFirewallPortFilter | Where-Object -Property LocalPort -EQ 80
Remove-NetFirewallRule -Name tcp80