Authorguda

Compare two filesystems

Lets run those command on the machines

New instanceOld instance
find / -xdev | sort > new.txt find / -xdev | sort > old.txt

Pull the files locally

scp -i ~/.ssh/somekey [email protected]:/new.txt  /tmp/new.txt
scp -i ~/.ssh/somekey [email protected]:/old.txt  /tmp/old.txt

Then use this great delta tool to compare the files

delta -s /tmp/new.txt /tmp/old.txt

Using md5 sums

And a using md5 sums – this is slow!

# On the new instance

find / -xdev -type f -exec  md5sum {} \; > new-files.txt
find / -xdev -type d | sort > sorted.new-folders.txt
sort  -k2  new-files >sorted.new-files.txt 

# On the old instance

find / -xdev -type f -exec  md5sum {} \; > old-files.txt
find / -xdev -type d | sort > sorted.old-folders.txt
sort  -k2  old-files >sorted.old-files.txt 

How to pull files from remote sftp

Create a script with the commands to pull the files and the remove them from the remote server

get -r upload/* incoming/
rm upload/*

You will need a cron

0 5 * * * /usr/bin/sftp -b batchfile.sh [email protected]

I recommend using systemd so that you can have logs

Where is more clear to do line break

Continue reading

Create AP on ubuntu

Continue reading

Check to dns zones

We are migrating from Cloudflare to route53 and want to make sure that all the records are migrated correctly.

records = %w(
  www
  blog
)

records.each do |record|
  aws = `dig +noall +answer www.example.com |tr '\t' ' ' | cut -d' ' -f1,3,4,5`
  cf = `dig +noall +answer www.example.com @1.1.1.1|tr '\t' ' ' | cut -d' ' -f1,3,4,5`

  if aws != cf
    puts("\nerror:")
    puts(aws)
    puts(cf)
  end
end

terraform bash shorcuts

Do you enjoy switching between us-east-1 and eu-central-1? If not here are some shortcuts which might make your day.

function change_region(){
  folder_name=`pwd`
  new_region=$1
  old_region=$2
  new_folder="${folder_name/$old_region/$new_region}"
  cd $new_folder
}

function production(){
  change_region 'terraform_production' 'terraform_development'
}


function development(){
  change_region 'terraform_development' 'terraform_production'
}

function us(){
  change_region 'us-east-1' 'eu-central-1'
}


function eu(){
  change_region 'eu-central-1' 'us-east-1'
}


How to give better examples

Continue reading

Rails free hosting

If you want free hosting, I mean free, not-cheap or other kinds of hosting. The only option which I know for now is Heroku.

There are some websites which advertise them as free rails hosting but they are paid.

So stay safe with the good old, slow on boot but very stable and enjoyable to work Heroku!

Akonadi KDE

Continue reading

Make tables visible on postgres after pgloader

Hello folks,

You have just used the pgloader to import some database in postgres but when you do

space_util=# \dt
Did not find any relations.

The problem is that you have to fix the search path for your tables.

Here is how to do it (or check the link for more ways)

space_util=# ALTER DATABASE space_util SET search_path = space_util,public;
space_util=# \dt
                                    List of relations
   Schema   |                           Name                           | Type  |  Owner   
------------+----------------------------------------------------------+-------+----------
 space_util | some_nice_table | table | postgres

© 2021 Gudasoft

Theme by Anders NorénUp ↑