Table of Contents

Linux. backup

Backup

SSH

#/etc/ssh/sshd_config

PermitRootLogin without-password
PubkeyAuthentication yes
service sshd restart

check session (specially for X)

ls /usr/bin/*session

check x application

dpkg -l|egrep -i "(kde|gnome|lxde|xfce|mint|unity|fluxbox|openbox)" | grep -v library

packages depends

apt-cache -o APT::Cache::GivenOnly=1 dotty gnome-system-tools | dot -T png > out.png

find GUI applications

apt-cache rdepends  --installed libx11-6

get large packages

sudo apt-get install wajig

wajig large

dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 10

get installed meta package ( to clear gui)

awk 'BEGIN{

  FS=" - ";
  findmeta="apt-cache search . | grep -i \"metapackage\\|meta-package\"";
  while ((findmeta | getline) > 0)  meta[$1]=$2;
  FS=" ";
  findinstalled="dpkg --get-selections";
  while ((findinstalled | getline) > 0) {
      if ($1 in meta) print $1" - "meta[$1]
  }

}'

clear fail2ban sqlite base

sqlite3 /var/lib/fail2ban/fail2ban.sqlite3 \
  "DELETE FROM bans WHERE DATE(timeofban, 'unixepoch') < '2021-08-19'; VACUUM;"

full local backup to tmp

tar -czvf - –one-file-system –ignore-failed-read –exclude=/backup.tar.gz –exclude=/proc –exclude=/tmp –exclude=/mnt –exclude=/dev –exclude=/sys –exclude=/run –exclude=/media –exclude=/var/log –exclude=/var/cache/apt/archives –exclude=/var/lib/lxcfs / | pv | cat > /tmp/bot-ar-`date +%m-%d-%Y`.tgz

tar -czvf - –one-file-system –ignore-failed-read /boot | pv | cat > /tmp/bot-ar-boot-`date +%m-%d-%Y`.tgz

  ssh root@bot.ip2u.ru 'cd / && tar -cvf - --exclude=/backup.tar.gz --exclude=/proc --exclude=/tmp --exclude=/mnt --exclude=/dev --exclude=/sys --exclude=/run --exclude=/media --exclude=/var/log --exclude=/var/lib/lxcfs/ --exclude=/var/cache/apt/archives  / | gzip -9 ' |  pv | cat > /mnt/d/backup/bot-ar/bot-ar-`date +%m-%d-%Y`.tgz
 

tar -cf - –exclude=/backup.tar.gz –exclude=/proc –exclude=/tmp –exclude=/mnt –exclude=/dev –exclude=/sys –exclude=/run –exclude=/media –exclude=/var/log –exclude=/var/cache/apt/archives / | brotli | pv | cat > /tmp/bot-ar-`date +%m-%d-%Y`.tar.bt

* local run save to ssh
   tar -cvf - --exclude=/backup.tar.gz --exclude=/proc --exclude=/tmp --exclude=/mnt --exclude=/dev --exclude=/sys --exclude=/run --exclude=/media --exclude=/var/log --exclude=/var/lib/lxcfs/ --exclude=/var/cache/apt/archives / | gzip -9 | ssh user@remote_server.example.com 'cat > /path/to/backup/bot-ar-`date +%m-%d-%Y`.tgz'