A great blog post showing how to backup an ssd with squashfs and dd.
Here is a pdf version
Page 3 of 30
I would like to know if someone is using the ssh on my servers. That’s why I have put a telegram notification. Here is how it works
Put in ssh/sshrc
#!/bin/bash
telegram-send -g "Access $SSH_TTY $SSH_CONNECTION `id`" &
Of course you need to setup your telegram-send
Lets run those command on the machines
New instance | Old instance |
find / -xdev | sort > new.txt | find / -xdev | sort > old.txt |
Pull the files locally
scp -i ~/.ssh/somekey ec2-user@10.1.22.1:/new.txt /tmp/new.txt
scp -i ~/.ssh/somekey ec2-user@10.1.19.1:/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
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 user@sftp.example.com
I recommend using systemd so that you can have logs
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
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'
}
© 2024 Gudasoft
Theme by Anders Norén — Up ↑